-
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 --strict_repo_env
option
#24404
base: master
Are you sure you want to change the base?
Add --strict_repo_env
option
#24404
Conversation
…AZEL_HTTP_RULES_URLS_AS_DEFAULT_CANONICAL_ID=0`)
- Get `--repo_env` fallback from `clientEnv` not `System`. Fixes issue where server process would "cache" environment variables. Broken since 3ebf658 (v5). - Feed `--action_env=X=Y` into into strict repo env (for consistency, the general behaviour ought to be removed) - Stray `//` marker
The CI failure flushed out a potential bug. With this issue, any changes to |
Could you split the fix into a separate PR? That would make it easier to cherry-pick into patch releases and Bazel 8. Since |
Stale environment issue split to #24433 (this PR is dependent on the fix for tests to pass, so I'll leave it here as well and rebase once merged). |
My initial thoughts were to keep this as a project preference, since currently many repository rules are heavily influenced by the host environment (sometimes intentionally). But if this change is being viewed as something to move towards, it may make sense to classify this as an incompatible change like with On a related note, there are a few places that use the "old" repo environment in
And for sake of completion, the client environment is directly used in these places.
The only spot of concern for me here is the download manager. Seems like in its current state, this PR may introduce some fragmentation (though such fragmentation would have already been possible with |
…ate relevent docs
Thanks for compiling this list, I'll have to think about this more. Since some repo rules do depend on the environment quite heavily, have you considered making this behavior configurable on the |
No, but only because I didn't think to. I'm not sure what such an API would look like. There is Some questions (not necessarily directed at anyone, just to help with ideation). Looking even further beyond this, a case could even be made for sandboxing certain repository rules. The download repos created by |
This PR introduces a new flag
--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).See
test_execute_environment_strict_vars
insrc/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 withuse_default_shell_env = True
) except those specified within the defining rule. Given the entity targeted by the new flag is a repo rule, I think this makes sense and any further strictness (like blocking implicit usage of variables without establishing a dependency) would be better addressed independently. Same goes for regular rules which can have some counterintuitive behaviors (e.g. only--[host_]action_env=X=Y
is accessible,--[host_]action_env=Y
will be missing, at least last I checked).Addresses #10996