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

Change where bazelrcs are read from, and make it easier to control which ones are read. #4502

Closed
drigz opened this issue Jan 22, 2018 · 59 comments
Assignees
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request

Comments

@drigz
Copy link
Contributor

drigz commented Jan 22, 2018

Description of the feature request:

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.

What operating system are you running Bazel on?

Ubuntu 14.04

What's the output of bazel info release?

release 0.9.0

@iirina iirina added type: feature request P2 We'll consider working on this in future. (Assignee optional) category: misc > misc labels Jan 23, 2018
@iirina iirina self-assigned this Jan 23, 2018
@ixdy
Copy link
Contributor

ixdy commented Jan 23, 2018

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.

@helenalt helenalt added P1 I'll work on this now. (Assignee required) and removed P2 We'll consider working on this in future. (Assignee optional) labels Jan 24, 2018
@helenalt
Copy link
Contributor

@jhfield @lberki please help prioritize an owner as this affects multiple users

@lberki lberki assigned cvcal and unassigned iirina Jan 25, 2018
@lberki
Copy link
Contributor

lberki commented 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.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.

WDY'allT?

@iirina
Copy link
Contributor

iirina commented Jan 25, 2018

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.

Is it possible to specify in the WORKSPACE file the location of the bazel.rc file? So that every project could put bazel.rc wherever they want.

@lberki
Copy link
Contributor

lberki commented Jan 25, 2018

Specifying it in the WORKSPACE file doesn't work; the rcfile is parsed from the launcher, which doesn't speak Skylark.

@drigz
Copy link
Contributor Author

drigz commented Jan 25, 2018

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.

@cvcal
Copy link
Contributor

cvcal commented 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.

@cvcal
Copy link
Contributor

cvcal commented Jan 25, 2018

The current workaround: If this is the best place for you to keep workspace-wide options, the rc file next to the bazel binary could import %workspace%/bazel/bazel.rc.
I realize this isn't a solution, since this request is to change the standard, but I thought I should mention that.

@drigz
Copy link
Contributor Author

drigz commented Jan 25, 2018

Excellent points, Chloe. After collecting the info below, I have realized it's even more complicated than I thought. I've listed in decreasing precedence and only summarized the unix behaviour; some of the source links describe behaviour on other platforms. (any mistakes my own)

maven (source)

  • specified with --settings
  • A user’s install: ${user.home}/.m2/settings.xml
  • The Maven install: ${maven.home}/conf/settings.xml

(note: someone patched the maven script to support per-project settings)

gradle (sources 1 and 2)

  • $WORKSPACE/settings.gradle (a Groovy script)
  • $WORKSPACE/gradle.properties (a key-value file)
  • ~/.gradle/gradle.properties (a key-value file)

npm (source)

  • per-project config file (/path/to/my/project/.npmrc)
  • per-user config file (~/.npmrc)
  • global config file ($PREFIX/etc/npmrc)
  • npm builtin config file (/path/to/npm/npmrc)

pip (source)

  • inside a virtualenv: $VIRTUAL_ENV/pip.conf
  • per-user: ~/.config/pip/pip.conf
  • legacy per-user: ~/.pip/pip.conf
  • site-wide: /etc/pip.conf
  • alternative site-wide: /etc/xdg/pip/pip.conf

gem (source)

  • ~/.gemrc
  • /etc/gemrc

cargo (source)

  • $PWD/.cargo/config
  • $PWD/../.cargo/config
  • $PWD/../../.cargo/config
  • and so on until: /.cargo/config
  • $HOME/.cargo/config

(this seems too clever for its own good...)

current Bazel

(I'm not sure about order of precedence here)

  • EITHER specified with --bazelrc (only the first use, repeated uses are silently ignored)
  • OR $WORKSPACE/.bazelrc
  • OR ~/.bazelrc
  • and all of:
  • $WORKSPACE/tools/bazel.rc
  • bazel.bazelrc next to the binary
  • /etc/bazel.bazelrc

Bazel: Klaus' proposal

  • (presumably --bazelrc, but it wasn't mentioned)
  • per-user-per-project-per-clone: $WORKSPACE/.bazelrc (this concept is non-standard)
  • per-project: $WORKSPACE/tools/bazel.rc
  • per-user: $WORKSPACE/.bazelrc
  • per-machine-type: bazel.bazelrc next to the binary (this concept is non-standard)
  • global: $WORKSPACE/.bazelrc

@cvcal
Copy link
Contributor

cvcal commented Jan 26, 2018

Thanks for the investigation! It's a complex world out there...
When you say Workspace in the context of Bazel, I assume you mean https://docs.bazel.build/versions/master/build-ref.html#workspace, but I'm unsure what it means in the context of gradle. I'll assume similar. The cargo solution seems excessive, and I dislike relying on the working directory for settings like this, so I’m ignoring that one :)

My understanding of Klaus's proposal, which might very well be tainted with my own opinions, so might not mirror the document exactly, is closer to the following:

  • per-user: $HOME/.bazelrc
    • what currently is loaded when --bazelrc isn't provided, I think Klaus's intended suggestion is that this file be loaded independently of the --bazelrc flag.
    • In Blaze, we have this replace-if-present logic because we intend there to only be 2 rc files, master and user, and the user can specify a specific file if the default one isn't acceptable. Unfortunately, in the bazel-land of more than 2 rc files, this replacement logic seems more confusing than helpful.
  • per-machine-type: bazel.bazelrc next to the binary
    • This is how blaze finds its master rc, and is largely inherited from that. It can be useful when there are different binaries, we benefit from the versioning this gives us internally, but I’m not sure how useful this is externally.
  • per-user-per-project-per-clone: $WORKSPACE/.bazelrc
    • I'm unclear on how this is better than having separate user and project rc files. Config flags allow for some fanciness there if absolutely necessary, and I think having this and the tools/ one is confusing
  • per-project: $WORKSPACE/tools/.bazelrc
    • You are suggesting replacing this "tools" directory with "bazel" yes? Or is there something different?
  • global: /etc/bazel.bazelrc.
    • This is similar to gem and pip’s site_wide configuration files, which is good.

@cvcal
Copy link
Contributor

cvcal commented Jan 26, 2018

@aehlig, since we're talking about your design doc 😄

@drigz
Copy link
Contributor Author

drigz commented Jan 26, 2018

per-project: $WORKSPACE/tools/.bazelrc
You are suggesting replacing this "tools" directory with "bazel" yes? Or is there something different?

Yep. Having seen that we currently have .bazelrc, bazel.rc and bazel.bazelrc, I'd propose using bazel/bazel.bazelrc - although that is very many bazels, and this is very much bikeshedding. I'd be fine with $WORKSPACE/.bazelrc or $WORKSPACE/bazel.rc.

per-user-per-project-per-clone: $WORKSPACE/.bazelrc
I'm unclear on how this is better than having separate user and project rc files.

We have found it useful for using --action_env to set user-specific config (eg name of dev cluster) that you wouldn't want to affect the action_env of every other project you use. However, this use case would be equally well served by using import in $WORKSPACE/tools/bazel.rc.

@cvcal
Copy link
Contributor

cvcal commented Jan 26, 2018

Yep. Having seen that we currently have .bazelrc, bazel.rc and bazel.bazelrc, I'd propose using bazel/bazel.bazelrc - although that is very many bazels, and this is very much bikeshedding. I'd be fine with $WORKSPACE/.bazelrc or $WORKSPACE/bazel.rc.

bazel.rc is the release candidate, it's a binary (or at least, it is internally, I'm pretty sure for Bazel too). I agree the naming's a mess :) but I think this particular thing isn't going to change.

For config files, I think the file extension should be enough, .bazelrc is as descriptive as bazel.bazelrc, but I think the full filename is only checked in the next-to-binary case, and that's largely due to the way we do things internally, so no opinion there.

Also agreed on the bikeshedding, though if we're going to make a change in this realm, file & directory naming is a big part of that, so some amount of care is justified.

We have found it useful for using --action_env to set user-specific config (eg name of dev cluster) that you wouldn't want to affect the action_env of every other project you use. However, this use case would be equally well served by using import in $WORKSPACE/tools/bazel.rc.

Above you say you'd be fine with $WORKSPACE/.bazelrc instead of using the intermediate directory "bazel" or "tools", is this a contradiction of that?
Regardless, in terms of specificity, all WORKSPACE-relative paths are equivalent, bazel/ tools/ or otherwise. Is that wrong?

More specific rc files can easily have imports to common files that are shared between projects/users/clones, whichever. It's the other direction that's hard, so I'd rather err on the side of making these locations too specific, within reason.

@cvcal
Copy link
Contributor

cvcal commented Jan 26, 2018

I think this is the list we're working from:

  • user-specified: --bazelrc (making this not remove the user-home rc)
  • per-user: $HOME/.bazelrc
  • bazel-team provided, per installation setup: bazel.bazelrc next to the binary (might be unnecessary?)
  • per-workspace: $WORKSPACE/.bazelrc (maybe with a tools/ or bazel/ intermediate directory)
  • global: /etc/bazel.bazelrc.

We could then have different trigger flags for these. imperfectly, --[no]home_bazelrc --[no]binary_bazelrc --[no]workspace_bazelrc --[no]global_bazelrc. This might be too much though, trimming this down if one or more of these is in clear excess would be good. Do the binary rc and the global rc serve different cases?

For an example of the type of configuration that's possible with the above without necessarily needing a file that configures for the intersection of user and project. The user's directory can easily have --config triggered options that the user then uses in accordance with a specific project:
<in $HOME/.bazelrc, user-specific>

build:project_x --action_env=projectXDevCluster
build:project_x --something_else

<in $WORKSPACE/.bazelrc, probably shared and version controlled>

# optional, we could also expect devs testing in an environment to type out this config on the command line
build --config=project_x 

@cvcal
Copy link
Contributor

cvcal commented Jan 26, 2018

@sergiocampama brings up the ordering problem, since more specific options should override competing options from a more general source. The three "master" rcs above, binary, workspace and global, don't have an obvious ranking. Maybe global < binary < workspace, but there are some cases where that wouldn't work.

@sergiocampama
Copy link
Contributor

IMO the next-to-binary rc should be provided by the bazel team in the distinct packages for release, like homebrew (macOS), chocolatey (Windows) and apt-get (linux). Given that this is the set of options coming from the bazel developers, it should be the most general one.

/etc/bazel.bazelrc could be set by system admins for specific group of developers, so it could be regarded as a bit more specific than the binary one. Don't know what the windows version could like like for that.

The $WORKSPACE one could be set by team leads for a project, so it's more specific that the /etc/bazel.bazelrc

Developers sets their own in $HOME which is more specific.

Finally the --blazerc gets loaded since it's per invocation, the most specific one.

WDYT?

@sergiocampama
Copy link
Contributor

You could also divide this into 2 groups, master (binary, /etc) and user (workspace, home), and have 2 flags to disable these --nomaster_bazelrc and --nouser_bazelrc. Or similar

@aj-michael
Copy link
Contributor

Hardcoding /etc/bazel.bazelrc is unfortunate for testing reasons. We currently have no test coverage that it works, because any such test would require writing to /etc/bazel.bazelrc which is outside of the test sandbox. It would be nice if this location were configurable.

@aehlig
Copy link
Contributor

aehlig commented Feb 13, 2018 via email

@cvcal cvcal changed the title Allow putting bazel.rc (and others) in a bazel/ subdir Change where bazelrcs are read from, and make them easier to configure. Feb 13, 2018
openstack-gerrit pushed a commit to openstack-infra/gerrit that referenced this issue Aug 10, 2018
Since: [1] Bazel changed the list of resource file locations.
Adapt to that list and move `%workspace%/tools/bazelrc` to
`%workspace%/.bazelrc`. See: [2], [3] for more details.

[1] bazelbuild/bazel@ec83598
[2] bazelbuild/bazel#4502
[3] bazelbuild/bazel#5756

Change-Id: Ia13c71bcff7036e2f5541618b28713d9b0d77040
bazel-io pushed a commit that referenced this issue Aug 20, 2018
Fixes #5906, removes the assert that the workspace exists, which I incorrectly added in the fix to #4502.

RELNOTES: None.
PiperOrigin-RevId: 209424088
bazel-io pushed a commit that referenced this issue Aug 22, 2018
*** Reason for rollback ***

Will add try-import before rolling this out, it won't make the 0.17 cut

The rc list is once again:
- %workspace%/tools/bazel.rc (unless --nomaster_bazelrc)
- %binary_dir%/bazel.bazelrc (unless --nomaster_bazelrc)
- system rc, /etc/bazel.bazelrc or in %ProgramData% for Windows (unless --nomaster_bazelrc)
- the first of the following gets called the "user" bazelrc
  - path passed by flag --bazelrc
  - %workspace%/.bazelrc
  - $HOME/.bazelrc

Reopen #4502

*** Original change description ***

Change the list of rc files accepted.

The new list is hopefully a bit more consistent, as:
- system rc (unless --nosystem_rc)
- workspace, %workspace%/.bazelrc (unless --noworkspace_rc)
- user, $HOME/.bazelrc (unless --nohome_rc)
- command-line provided, passed as --bazelrc or nothing if the flag is absent.

This list removes two less than useful locations, duplication in the Workspace directory, and the rc next to the bazel binary. This location made sense at Google but is generally nonsensical elsewhere so we are removing it. It also stops the user local rc file from being overriden by passing in a custom file in --bazelrc.

In both old and new, --ignore_all_rc_files disables all of the above.
For a transition period, any file that you would have loaded but was not read will cause a WARNING to be printed. If you want the old file to still be read without moving its location, you can always import it into one of the new standard locations, or create a symlink.

Closes #4502, except for cleanup to remove the warning after a transition period of 1 Bazel version has passed.

RELNOTES[INC]: New bazelrc file list.

PiperOrigin-RevId: 209797467
@cvcal cvcal reopened this Aug 22, 2018
@cvcal
Copy link
Contributor

cvcal commented Aug 22, 2018

Won't be making it in to 0.17, will roll forward to 0.18 once the release is cut

perfinion added a commit to perfinion/tensorflow that referenced this issue Aug 31, 2018
Bazel 0.17.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
perfinion added a commit to perfinion/tensorflow that referenced this issue Sep 11, 2018
Bazel 0.17.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
perfinion added a commit to perfinion/tensorflow that referenced this issue Sep 15, 2018
Bazel 0.17.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
perfinion added a commit to perfinion/tensorflow that referenced this issue Sep 17, 2018
Bazel 0.18.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
@ittaiz
Copy link
Member

ittaiz commented Sep 19, 2018

@cvcal shouldn't this commit with ignore_all_rc_files have come with release notes? Reason why I'm asking is because I started using it in a library I maintain and saw that older versions fail. I went to the release notes to see when it got in but couldn't find it in the change-log.

Also- the ignore_all_rc_files flag is equivalent to putting --bazelrc=/dev/null --nomaster --nohome_rc --nosystem_rc (if they are put last on the command line)? The answer will help me get the same functionality while supporting old bazel versions

@ittaiz
Copy link
Member

ittaiz commented Sep 20, 2018

@cvcal so apparently nohome_rc is also only available from 0.17.1 :(
Am I correct in assuming that the following options will give me a no RC build on bazel 11-16? ( “bazelrc=/dev/bull —nomaster”) If so I’ll just see if I can add a conditional on my code

@cvcal
Copy link
Contributor

cvcal commented Sep 20, 2018

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.

@ittaiz
Copy link
Member

ittaiz commented Sep 20, 2018

ended up bumping to 0.15.2 as minimal version and using ignore_all_rc_files

@cvcal
Copy link
Contributor

cvcal commented Sep 20, 2018

15 is the first version with the flag? That sounds right

@ittaiz
Copy link
Member

ittaiz commented Sep 20, 2018 via email

perfinion added a commit to perfinion/tensorflow that referenced this issue Sep 28, 2018
Bazel 0.18.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
@ensonic
Copy link
Contributor

ensonic commented 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
Copy link
Contributor

cvcal commented 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
Copy link
Contributor

ensonic commented 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
Copy link
Contributor

cvcal commented 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
Copy link

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.

werkt pushed a commit to werkt/bazel that referenced this issue Oct 19, 2018
Leave functions that make file accesses in the file library, and general blaze utilities in the blaze_util file, but move the functions that boil down to string manipulation and path formatting to their own file. (With the exception of getCWD, since absolute path syntax is relevant here.)

Doing this largely to consolidate all Windows path control into a single place, so that it's easier to notice inconsistencies. For instance, ConvertPath currently makes Windows paths absolute, but not Posix paths, and MakeAbsolute relies on this behavior. In addition, JoinPath assumes Posix path syntax, which leads to some odd looking paths. These will be fixed in a followup change.

(Found these issues while working on bazelbuild#4502, trying to fix the windows-specific system bazelrc.)

RELNOTES: None.
PiperOrigin-RevId: 199368226
werkt pushed a commit to werkt/bazel that referenced this issue Oct 19, 2018
For paths passed to Bazel on the command line, the shell expands these variables, but for hardcoded defaults, we must make the library call ourselves.

We do not add similar support in Posix systems, where it is less common to rely on standard path-related variables.

Prerequisit for issue bazelbuild#4502.

RELNOTES: None.
PiperOrigin-RevId: 201183214
mihaimaruseac pushed a commit to tensorflow/tensorflow that referenced this issue Mar 26, 2019
Bazel 0.18.0 will contain a change for which rc files it accepts.
bazelbuild/bazel@ec83598
bazelbuild/bazel#4502

Old bazel used to read %workspace%/tools/bazel.rc. New bazel will not
read that and instead will only read %workspace%/.bazelrc.

Signed-off-by: Jason Zaman <jason@perfinion.com>
@gibfahn
Copy link
Contributor

gibfahn commented Sep 12, 2019

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 config
export CARGO_HOME="$XDG_DATA_HOME/cargo"
# Npm allows customising
export 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: misc > misc P1 I'll work on this now. (Assignee required) type: feature request
Projects
None yet
Development

No branches or pull requests