-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
Add support for specifying --bazelrc multiple times #7489
Comments
Are there any objections to this? |
Bazel should at least warn that it ignores I opt for a warning instead of an error, because adding an error would be an incompatible change while adding a warning isn't. (A few months ago the Bazel team decided to adhere to our own incompatible change policy. Adding a new error is an incompatible change. Per policy I had to add an |
@burkpojken : Did you know bazelrc files can include other bazelrc files? Could everyone's user rc file, or every project's project-rc file include the common rc file? |
HI! |
I never said it was. I don't know why Bazel supports just one user-rc file. Current behavior: multiple I'm looking at adding a warning, but it takes longer than I expected because the code is complex. |
Do you mean loading |
Hello @laszlocsomor , We are starting to work on a feature that requires this behavior and we are from the same workgroup as @burkpojken . We understand the need for this behavior and would like to answer the following question.
The intention of this feature request is not to specify multiple As you have stated previously, the current behavior is that the first file is used and the rest is ignored. I believe this is the behavior we want to change. We hope that it won't be a completely new behavior because today it is possible for options placed in different Do you think this is a desirable feature for Bazel upstream ? |
Hi @egechir ,
Thanks for clarifying. That makes sense to me, but it seems to be different than @burkpojken's request:
If I understand correctly, this is about referencing workspaces either in bazelrc files or in
Hard question. I understand your use case and I think it'd be a nice feature. But I don't think it's desirable for upstream. It would be if many people requested the feature and implementing it benefited many, but that doesn't seem to be the case. There's another reason I'm hesitant to consider implementing or upstreaming this feature: I suspect certain Google-internal logging infrastructure to depend on The workaround is to have a single bazelrc file and import other bazelrc files. I understand it's not as flexible as multiple
Sure. If you wanted to implement this feature, I'd happily review the PR and run it against internal tests and tell you of any complications. |
Thanks for the reply @laszlocsomor . |
Thanks! (And sorry I didn't reopen when I said so, forgot it like I never wrote it..) |
I have a question. I'm working with egechir on this issue. I've tried changing the "bazelrc" definition in BazelStartupOptionsModule.java so that it has "allowMultiple = true" and so that the field is now a "List". I'm wondering where in the code it will use this data so that I can make it accept and pass on a List rather than a single String. Do you have any advice there? |
@emlrsua : It's not used from Java. The flag is only defined in Java to attach documentation to it: bazel/src/main/java/com/google/devtools/build/lib/bazel/BazelStartupOptionsModule.java Line 35 in d9fe1d4
The actual flag handling is in C++, here:
|
Hi @laszlocsomor, Please kindly reopen the issue if you think the case is valid, and redirect if you are no longer active on bazel. I'd like to raise this again on behalf of Twitter, multiple
The reality is, per https://docs.bazel.build/versions/master/guide.html#bazelrc-the-bazel-configuration-file, multiple |
@meisterT could you please re-route |
Thanks for reopening @meisterT. This would be useful also for Ericsson, for the same reasons mentioned by @wisechengyi. |
I'm in favor of supporting this and can't think of good reasons not to. 🤔 The concerns that Laszlo had earlier about backend systems (e.g. logging, monitoring, ...) assuming that --bazelrc is a singular option might be annoying if true, I agree with that. But as you all said, Bazel already supports multiple sources of bazelrcs already anyway, so the concept of having multiple files at least isn't new. Would someone like to contribute a PR? My team would be happy to review and merge. |
Happy to take a stab at this. Hoping to have something out by EOY, but if anyone wants to jump in prior, please do by all means. |
Review out at #12740 |
Address #7489 ### Motivation Multiple --bazelrc on CLI would be useful for us for various reasons: Mostly importantly, we will have very long argument lists to pass to bazel query, so they have to be in a bazelrc file. `import/try import` in bazelrc would still work but very awkwardly. For example, if there are multiple bazelrc files to import, say `A` and `B`, import `A` needs to be added into `$WORKSPACE/.bazelrc` import `B` needs to be added into `A` meaning the former bazelrc file needs to know what comes next. Therefore allowing multiple --bazelrc would greatly improve the ergonomics, so the caller can create and append the new bazelrc without modifying the previous rc files. ### Note Options passed on CLI will still overwrite any options specified in any bazelrcs. ### Result `bazel --bazelrc=x.rc --bazelrc=y.rc ...` now works. ``` --bazelrc (a string; default: see description) The location of the user .bazelrc file containing default values of Bazel options. This option can also be chained together. E.g. `--bazelrc=x.rc --bazelrc=y.rc` so options in both RCs will be read. Note: `--bazelrc x.rc y.rc` is illegal, and each bazelrc file needs to be accompanied by --bazelrc flag before it. If unspecified, Bazel uses the first .bazelrc file it finds in the following two locations: the workspace directory, then the user's home directory. Use /dev/null to disable the search for a user rc file, e.g. in release builds. ``` Closes #12740. PiperOrigin-RevId: 364407234
Address #7489 ### Motivation Multiple --bazelrc on CLI would be useful for us for various reasons: Mostly importantly, we will have very long argument lists to pass to bazel query, so they have to be in a bazelrc file. `import/try import` in bazelrc would still work but very awkwardly. For example, if there are multiple bazelrc files to import, say `A` and `B`, import `A` needs to be added into `$WORKSPACE/.bazelrc` import `B` needs to be added into `A` meaning the former bazelrc file needs to know what comes next. Therefore allowing multiple --bazelrc would greatly improve the ergonomics, so the caller can create and append the new bazelrc without modifying the previous rc files. ### Note Options passed on CLI will still overwrite any options specified in any bazelrcs. ### Result `bazel --bazelrc=x.rc --bazelrc=y.rc ...` now works. ``` --bazelrc (a string; default: see description) The location of the user .bazelrc file containing default values of Bazel options. This option can also be chained together. E.g. `--bazelrc=x.rc --bazelrc=y.rc` so options in both RCs will be read. Note: `--bazelrc x.rc y.rc` is illegal, and each bazelrc file needs to be accompanied by --bazelrc flag before it. If unspecified, Bazel uses the first .bazelrc file it finds in the following two locations: the workspace directory, then the user's home directory. Use /dev/null to disable the search for a user rc file, e.g. in release builds. ``` Closes #12740. PiperOrigin-RevId: 364407234
Hello @wisechengyi , I'm working on a clean up effort for flags parsing. While reviewing the behavior of the flag
Bazel would ignore file-b instead of file-a. Considering our flag evaluation order, I would expect
I'm curious to know how is this being used for your specific use case. And if we were to make the change as described above, would it break you? |
Hi @aranguyen, This was intentional at the time of the PR to be backward compatible with the status before this change. https://docs.bazel.build/versions/main/guide.html
We (twitter) aren't using Are you by any chance speaking with @michajlo as he/she has provided feedbacks in this specific area in #12740? |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team ( |
Description of the problem / feature request:
Today it is not possible to add multiple --bazelrc options to the command line.
Feature requests: what underlying problem are you trying to solve with this feature?
We have some default options in a common bazelrc file that is used in many workspaces since the options are needed to build for our platform.
Today we need to add those options in all user .bazelrc WORKSPACE files.
If it would be possible to add multiple --bazelrc options on the command line we could have one rc file for the common parameters and still be able to use other bazelrc files for the user projects.
What operating system are you running Bazel on?
linux
What's the output of
bazel info release
?0.20.0
Have you found anything relevant by searching the web?
No
Any other information, logs, or outputs that you want to share?
The text was updated successfully, but these errors were encountered: