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

feature request: add a flag that tells bazel to include the current environment's variables #4093

Closed
schnaitterm opened this issue Nov 14, 2017 · 7 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request

Comments

@schnaitterm
Copy link

I understand the concept of wanting to have a sandboxed environment for builds on many software in order to maintain reproducibility, etc... but the fact that there is no way to tell bazel to do otherwise is an incredible hassle, especially when, for instance, you are using to build software in an HPC environment (cough TensorFlow cough) where everything is managed using environment modules. there should be a flag along the lines of --use-local-env (as in nvcc for CUDA). There's no good reason that I should have to wrap my compilers (Intel, in the current case) just to have them reload all the modules when the compiler is run so that it can find its licenses and what not. I tried using the --action_env option but it had absolutely no effect. We need an option to keep our local environment when building with bazel. Thanks

@nicolov
Copy link
Contributor

nicolov commented Nov 15, 2017

You can forward individual environment variables with build --action_env=MYVAR and test --test_env=MYVAR.

@benjaminp
Copy link
Collaborator

The C++ rules roll their own environment handling and thus have inconsistent behavior with --action_env. That's definitely a bug. #3320 is the meta issue for that.

If you've already managed to set the right env vars for CUDA once doesn't seem like it should be hard to copy that knowledge into the Bazel command line. At the very worst, you can have a Bazel wrapper that translates env into --action_env arguments. Blindly leaking all environmental state into builds is pretty smelly, so I'm not sure Bazel should support it.

@schnaitterm
Copy link
Author

@benjaminp that's why it should be an optional flag, but not the default behaviour. and the mentioning of CUDA was only an example of software that implements such a feature. Wrapping env into --action_env arguments is messy and would be stupid to make necessary, when this is functionality the software should have to begin with. If you are going to have a non-standard build system, it should at the very least of the option of doing certain things in a way that at least resembles standard. Bazel, so far, has proven to me to be unwieldy, convoluted, and downright confusing. I wouldn't use it if I didn't need to build software that depended on it

@aiuto
Copy link
Contributor

aiuto commented Apr 15, 2019

We would not want to add an option that simply forwards every environment variable. That would mean completely irrelevant variables (e.g. WINDOWID) would impact your build. Caching would be impossible. The only reasonable feature is where the user explicitly enumerates the set of variables they wish to pass on. action_env still seems the right way to approach this. We first have to fix things like #3320, but that is
time well spent anyway.

The first step beyond that would be try try expanding in the .bazelrc
build --action_env=MYVAR=${MYVAR}
If that does not work today, it is certainly a useful feature to add.

If not, one could roll their own interim solution.

  • wrapper script around bazel that creates bazel_env.inc, whose content is
    build --action_env=VAR=val
    for each VAR in the list of ones you want to export
  • have your .bazelrc import bazel_env.inc.

@aiuto aiuto added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Bazel General Bazel product/strategy issues and removed category: misc > misc labels Apr 15, 2019
@dslomov dslomov added team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website and removed team-Bazel General Bazel product/strategy issues labels Jul 23, 2019
@github-actions
Copy link

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 3 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 (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

@github-actions github-actions bot added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 28, 2023
@github-actions
Copy link

This issue has been automatically closed due to inactivity. If you're still interested in pursuing this, please reach out to the triage team (@bazelbuild/triage). Thanks!

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-OSS Issues for the Bazel OSS team: installation, release processBazel packaging, website type: feature request
Projects
None yet
Development

No branches or pull requests

6 participants