Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bazel does not read /etc/bazelrc #70911

Closed
guibou opened this issue Oct 10, 2019 · 2 comments · Fixed by #74976
Closed

Bazel does not read /etc/bazelrc #70911

guibou opened this issue Oct 10, 2019 · 2 comments · Fixed by #74976
Labels
0.kind: bug Something is broken

Comments

@guibou
Copy link
Contributor

guibou commented Oct 10, 2019

Describe the bug

By default and according to bazel documentation (https://docs.bazel.build/versions/master/guide.html#where-are-the-bazelrc-files), bazel is looking for a system-wide configuration is /etc/bazel.bazelrc.

In ba327a5 I decided to override this path and make it point in $out/etc/bazelrc. It was the easiest solution to pass arguments to bazel in order to fix a few runtime issues.

However it breaks the assumption that user can configure bazel using /etc/bazel.bazelrc.

To Reproduce

  • Use bazel from nixpkgs with nix run nixpkgs.bazel.
  • Set some bazel settings in your /etc/bazel.bazelrc file
  • Observe that bazel ignores this file

Expected behavior

I'm opening this bug report to discuss what should be the expected behavior here? Should we respect the /etc/bazel.bazelrc? If yes, I'll open a pull request to restore the previous behavior.

@guibou guibou added the 0.kind: bug Something is broken label Oct 10, 2019
@flokli
Copy link
Contributor

flokli commented Oct 10, 2019

I'll be in favour of keeping support for all paths specified in the documentation - having a system-wide /etc/bazel.bazelrc is something people might want to make use of, so we shouldn't take away that possibility.

We currently set the following options in bazelrc:

      build --distdir=${distDir}
      fetch --distdir=${distDir}
      build --copt="$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --copt="/g')"
      build --host_copt="$(echo $NIX_CFLAGS_COMPILE | sed -e 's/ /" --host_copt="/g')"
      build --linkopt="-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --linkopt="-Wl,/g')"
      build --host_linkopt="-Wl,$(echo $NIX_LDFLAGS | sed -e 's/ /" --host_linkopt="-Wl,/g')"
      build --host_javabase='@local_jdk//:jdk'
      build --host_java_toolchain='${javaToolchain}'

We should either patch these as defaults into nixos, or introduce reading from a distro-provided location (should be coordinated with bazel upstream).

I think adding a wrapper is a bit too much for all these options.

@guibou
Copy link
Contributor Author

guibou commented Oct 10, 2019

@flokli I do agree with your point of view. I'll try to propose a PR which restore the old behavior. In the meantime, I'm open to other comments on this issue.

Regarding the options you quote, they are used in a local .bazelrc during build only. The global bazelrc that I provide is way simpler:

build --override_repository=remote_java_tools_linux=/nix/store/syddjzd8w2vxh5ip2d01p5sf0gscr0gp-remote_java_tools_linux
build --distdir=/nix/store/xxz8rjkxs7ravd8zg8fm4qdrwdvxyxql-bazel-deps

Both were ad hoc solution for different problems, respectively issue #63096 and commit 67904dc.

guibou added a commit to guibou/nixpkgs that referenced this issue Dec 5, 2019
…ration

Some system may setup global informations (such as bazel cache location)
in /etc/bazel.bazelrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants