You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Change where bazelrcs are read from, and make it easier to control which ones are read. #4502
Check for bazel/bazel.rc in addition to tools/bazel.rc. This could also be done for tools/bazel and any other special files that can be in tools/.
Feature requests: what underlying problem are you trying to solve with this feature?
Projects that support multiple build systems prefer to keep the files separated as far as possible. However, Bazel forces you to add a tools/ top-level directory to use certain functionality. See this comment from cartographer-project/cartographer#834 which prompted this issue.
The bazel/ subdirectory is fairly common for builds that support multiple systems, eg gRPC, glog, Google Cartographer, Ceres Solver. Exceptions (ie projects with no bazel/ subdir) include TensorFlow and gRPC Java, although IMHO the latter is good example of where it would help clean things up.
Kubernetes is another project which would benefit from something like this. We currently have a .bazelrc in the repo root, which is overriding users' $HOME/.bazelrc, so we should fix this.
We don't have a tools/ directory (though we do have a build/), and I'm not super excited about creating tools/ solely for one file.
(assigning to @cvcal since she worked with option parsing more recently than both @lfpino and @iirina)
I think this is a good idea; tools/bazel.rc is mostly a heritage from our internal repository. I think using $WORKSPACE/bazel.rc is more reasonable than tools. I'm not thrilled about $WORKSPACE/bazel/bazel.rc, though -- why create a directory just for one file?
Migration will also need to be given some thought; we could either just change in a Bazel release since projects can simply symlink one location to the other to support building with Bazels both before and after the flag flip or have a release that supports both, then remove the old location in the subsequent release. I think the first plan is simpler and the migration costs are not too onerous.
I'm not thrilled about $WORKSPACE/bazel/bazel.rc, though -- why create a directory just for one file?
Seems like the reasoning is that a lot of projects already have the bazel directory.
Yes, and specifically that bazel/ is desirable name for projects that support other build systems. Also, $WORKSPACE/bazel.rc and $WORKSPACE/.bazelrc would be (even more) easily confused.
I actually was just talking to Luis and Klaus about this (context b/70843852 & b/36168162, for Bazel team members).
Bazel currently loads 3 master bazelrcs, or none, if --nomaster_bazelrc is passed. I find this horrible, there is no way for users to pick which of these files should be loaded, no way for one of these to be ignored while others kept. I'd rather we not add a 4th location from which we look for a master rc without improving this with a more granular switch.
On the question of which files should be in that list, Klaus had written a proposal for what the bazelrc world should look like a few years ago, hidden in https://www.bazel.build/designs/2016/06/21/environment.html. It doesn't contain exactly this suggestion, but might be a good starting point. I think it would be great if we can work something that is similar to the standards in other open source projects, but I don't know much about those standards so I can't speak to the WORKSPACE/bazel directory in particular.
Yes, --ignore_all_rc_files will do what it says for any Bazel where it exists. There weren't any release notes because this flag was mostly intended as an internal tool - it ignores everything, regardless of the other flags, so --ignore_all_rc_files --master_bazelrc (in bazel 17 or earlier) or --ignore_all_rc_files --home_rc <etc> (in bazel 18 or later) does not read any file, last flag does not win, in this case. These semantics are intentional, but not very user-friendly; this flag was mostly intended to allow different versions of Bazel (including google's Blaze) to have a single no-rc configuration, which is useful for tests.
This is not supported - we need a place that can make sense in different platforms and setups, and I'm not sure that .config is a standard location. If you care about backups in .config/, you should be able to create a thin bazelrc in HOME that imports the one in .config, which gets backed up, but that doesn't solve the clutter issue.
If it really is the standard as you say, then I don't know why it didn't come up earlier in the discussion about this change, we looked for standard config file locations earlier in this thread (see #4502 (comment)). Maybe we were wrong, but no one pointed it out, and so we stuck with the file location that a number of our users were already used to using.
I don't believe there's much appetite to change this list a second time, makes the release break a lot of people.
I definitely agree with no more changes to the list at this point. Also basically everything I've seen that supports ~/.config/foorc also reads ~/.foorc. So lets get this change out the door as-is then in a later release we can revisit adding~/.config/bazel/config to the list not removing ~/.bazelrc.
If it really is the standard as you say, then I don't know why it didn't come up earlier in the discussion about this change, we looked for standard config file locations earlier in this thread (see #4502 (comment)). Maybe we were wrong, but no one pointed it out, and so we stuck with the file location that a number of our users were already used to using.
FWIW the above tools mostly allow the user's bazel config to easily be moved to $XDG_CONFIG_HOME (~/.config) by reading an env var that can be set to point to the relevant directory.
# Cargo, mixes data and global configexport CARGO_HOME="$XDG_DATA_HOME/cargo"# Npm allows customisingexport npm_config_userconfig="$XDG_CONFIG_HOME/npm/config"# Gradle puts the cache and config together.export GRADLE_USER_HOME="$XDG_CACHE_HOME/gradle"# Pip supports $XDG_CONFIG_HOME by default: ~/.config/pip/pip.conf# maven and gem can't use the XDG spec.
Lots of other tools like git also have support for this, see the Arch Wiki Page for a list.
I don't believe there's much appetite to change this list a second time, makes the release break a lot of people.
That's reasonable, but is there a way to change this in a semver-minor fashion?
Ideally by adding a couple of options at the top of the per-user list, e.g.
$XDG_CONFIG_HOME/bazelrc
~/.config/bazelrc
~/.bazelrc
Alternatively by keeping the current defaults but also reading an env var, allowing users to do export BAZEL_CONFIG=${XDG_CONFIG_HOME:-~/.config}/bazelrc.
Right now the best workaround I've found for this is alias bazel="bazel --bazelrc $XDG_CONFIG_HOME/bazel/bazelrc", but that doesn't always work.
Reacted by Olek Wojnar, Mikhail Tymchuk, Adam Hitchcock, Jesse Somerville, dsisnero and Gilad Peleg
Activity
ixdy commentedon Jan 23, 2018
Kubernetes is another project which would benefit from something like this. We currently have a
.bazelrcin the repo root, which is overriding users'$HOME/.bazelrc, so we should fix this.We don't have a
tools/directory (though we do have abuild/), and I'm not super excited about creatingtools/solely for one file.helenalt commentedon Jan 24, 2018
@jhfield @lberki please help prioritize an owner as this affects multiple users
lberki commentedon Jan 25, 2018
(assigning to @cvcal since she worked with option parsing more recently than both @lfpino and @iirina)
I think this is a good idea;
tools/bazel.rcis mostly a heritage from our internal repository. I think using$WORKSPACE/bazel.rcis more reasonable thantools. I'm not thrilled about$WORKSPACE/bazel/bazel.rc, though -- why create a directory just for one file?Migration will also need to be given some thought; we could either just change in a Bazel release since projects can simply symlink one location to the other to support building with Bazels both before and after the flag flip or have a release that supports both, then remove the old location in the subsequent release. I think the first plan is simpler and the migration costs are not too onerous.
WDY'allT?
iirina commentedon Jan 25, 2018
Seems like the reasoning is that a lot of projects already have the
bazeldirectory.Is it possible to specify in the
WORKSPACEfile the location of thebazel.rcfile? So that every project could putbazel.rcwherever they want.lberki commentedon Jan 25, 2018
Specifying it in the
WORKSPACEfile doesn't work; the rcfile is parsed from the launcher, which doesn't speak Skylark.drigz commentedon Jan 25, 2018
Yes, and specifically that
bazel/is desirable name for projects that support other build systems. Also,$WORKSPACE/bazel.rcand$WORKSPACE/.bazelrcwould be (even more) easily confused.cvcal commentedon Jan 25, 2018
I actually was just talking to Luis and Klaus about this (context b/70843852 & b/36168162, for Bazel team members).
Bazel currently loads 3 master bazelrcs, or none, if --nomaster_bazelrc is passed. I find this horrible, there is no way for users to pick which of these files should be loaded, no way for one of these to be ignored while others kept. I'd rather we not add a 4th location from which we look for a master rc without improving this with a more granular switch.
On the question of which files should be in that list, Klaus had written a proposal for what the bazelrc world should look like a few years ago, hidden in https://www.bazel.build/designs/2016/06/21/environment.html. It doesn't contain exactly this suggestion, but might be a good starting point. I think it would be great if we can work something that is similar to the standards in other open source projects, but I don't know much about those standards so I can't speak to the WORKSPACE/bazel directory in particular.
76 remaining items
cvcal commentedon Sep 20, 2018
Yes,
--ignore_all_rc_fileswill do what it says for any Bazel where it exists. There weren't any release notes because this flag was mostly intended as an internal tool - it ignores everything, regardless of the other flags, so--ignore_all_rc_files --master_bazelrc(in bazel 17 or earlier) or--ignore_all_rc_files --home_rc <etc>(in bazel 18 or later) does not read any file, last flag does not win, in this case. These semantics are intentional, but not very user-friendly; this flag was mostly intended to allow different versions of Bazel (including google's Blaze) to have a single no-rc configuration, which is useful for tests.ittaiz commentedon Sep 20, 2018
ended up bumping to 0.15.2 as minimal version and using ignore_all_rc_files
cvcal commentedon Sep 20, 2018
15 is the first version with the flag? That sounds right
ittaiz commentedon Sep 20, 2018
Move bazel.rc to workspace root to support bazel-0.18.0
ensonic commentedon Oct 11, 2018
Using `$HOME/.bazelrc' will clutter the home-dir. Shouldn't this be $HOME/.config/.bazelrc ? Is this supported? For details check out https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
$HOME/.config is the fallback fro $XDG_CONFIG_HOME. This inderection lets the user/admin decide where to have configuration files (important for backups too).
cvcal commentedon Oct 11, 2018
This is not supported - we need a place that can make sense in different platforms and setups, and I'm not sure that .config is a standard location. If you care about backups in .config/, you should be able to create a thin bazelrc in HOME that imports the one in .config, which gets backed up, but that doesn't solve the clutter issue.
ensonic commentedon Oct 11, 2018
He seriously, you are compliant with the basedir spec for other files. Eg the cached resource are under ~/.cache/bazel/bazel_$USER/. The standard I pointed to is a quite established solution.
If you are looking for a java-impl: https://github.com/omajid/xdg-java
cvcal commentedon Oct 11, 2018
If it really is the standard as you say, then I don't know why it didn't come up earlier in the discussion about this change, we looked for standard config file locations earlier in this thread (see #4502 (comment)). Maybe we were wrong, but no one pointed it out, and so we stuck with the file location that a number of our users were already used to using.
I don't believe there's much appetite to change this list a second time, makes the release break a lot of people.
perfinion commentedon Oct 12, 2018
I definitely agree with no more changes to the list at this point. Also basically everything I've seen that supports
~/.config/foorcalso reads~/.foorc. So lets get this change out the door as-is then in a later release we can revisit adding~/.config/bazel/configto the list not removing~/.bazelrc.Move path-manipulation functions to own library file.
Add a utility function to accept windows-style envvars in paths.
Move bazel.rc to workspace root to support bazel-0.18.0
gibfahn commentedon Sep 12, 2019
FWIW the above tools mostly allow the user's bazel config to easily be moved to
$XDG_CONFIG_HOME(~/.config) by reading an env var that can be set to point to the relevant directory.Lots of other tools like git also have support for this, see the Arch Wiki Page for a list.
That's reasonable, but is there a way to change this in a semver-minor fashion?
Ideally by adding a couple of options at the top of the per-user list, e.g.
$XDG_CONFIG_HOME/bazelrc~/.config/bazelrc~/.bazelrcAlternatively by keeping the current defaults but also reading an env var, allowing users to do
export BAZEL_CONFIG=${XDG_CONFIG_HOME:-~/.config}/bazelrc.Right now the best workaround I've found for this is
alias bazel="bazel --bazelrc $XDG_CONFIG_HOME/bazel/bazelrc", but that doesn't always work.Drop the rc file flag.