[9.0.0] Add --experimental_strict_repo_env option#27780
Merged
meteorcloudy merged 1 commit intobazelbuild:release-9.0.0from Nov 25, 2025
Merged
[9.0.0] Add --experimental_strict_repo_env option#27780meteorcloudy merged 1 commit intobazelbuild:release-9.0.0from
--experimental_strict_repo_env option#27780meteorcloudy merged 1 commit intobazelbuild:release-9.0.0from
Conversation
This PR introduces a new flag `--experimental_strict_repo_env` which stops repository rules and module extensions from inheriting the client environment (making `--repo_env=NAME` more than just an advisory notice). When enabled up to 2 environment variables will still be forwarded (unless overridden or explicitly removed via `--repo_env==VARNAME`, see bazelbuild#26300 for more details); - `PATH` - All platforms - `PATHEXT` - Windows See `test_execute_environment_strict_vars` in `src/test/shell/bazel/starlark_repository_test.sh` for a demonstration. Note that the behavior is different to the similarly named `--incompatible_strict_action_env`, which stops _all_ environment variables (`--action_env` affects actions with `use_default_shell_env = True`) except those specified within the defining rule. This is by design as repository rules operate in an inherently non-hermetic domain, covering roles such as integrating with the C/C++ toolchain installed on the host. It does not make sense to lock down environment variables _by default_, this is best left up to individual projects and users. This flag is marked experimental to allow for testing and requirement discovery (e.g. env vars other than `PATH` that should be included). Closes bazelbuild#10996 Closes bazelbuild#24404. PiperOrigin-RevId: 836494750 Change-Id: Ic05e5ca47a14badb2cd23f810e775c3341ddfaa8
meteorcloudy
approved these changes
Nov 25, 2025
Merged
via the queue into
bazelbuild:release-9.0.0
with commit Nov 25, 2025
6b55942
46 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a new flag
--experimental_strict_repo_envwhich stops repository rules and module extensions from inheriting the client environment (making--repo_env=NAMEmore than just an advisory notice).When enabled up to 2 environment variables will still be forwarded (unless overridden or explicitly removed via
--repo_env==VARNAME, see #26300 for more details);PATH- All platformsPATHEXT- WindowsSee
test_execute_environment_strict_varsinsrc/test/shell/bazel/starlark_repository_test.shfor a demonstration.Note that the behavior is different to the similarly named
--incompatible_strict_action_env, which stops all environment variables (--action_envaffects actions withuse_default_shell_env = True) except those specified within the defining rule. This is by design as repository rules operate in an inherently non-hermetic domain, covering roles such as integrating with the C/C++ toolchain installed on the host. It does not make sense to lock down environment variables by default, this is best left up to individual projects and users.This flag is marked experimental to allow for testing and requirement discovery (e.g. env vars other than
PATHthat should be included).Closes #10996
Closes #24404.
PiperOrigin-RevId: 836494750
Change-Id: Ic05e5ca47a14badb2cd23f810e775c3341ddfaa8
Commit 60bc017