Howdy all,
currently, --action_env is affecting environment variables for Bazel actions, but also the environment for repository rules. Because of that it is possible to run Bazel as bazel build --action_env=CC=/usr/bin/clang //... when the user means CC=/usr/bin/clang bazel build //.... Using --action_env is tempting, since it can be put into .bazelrc file and be a part of configs there, allowing you to have single flag build, e.g. bazel build --config=cuda //....
The problem with that is that changing --action_env invalidates entire action graph when a environment variable changes, even though only one repository rule depended on the variable, it's output was the same, and change didn't need to be propagated further.
I assume there are multiple possible solutions, my first guess would be to add a --repo_env Bazel option that only affected repository rules and not actions, but I'll leave this to experts.
I'll also try to generalize the problem a bit - we don't need environment variables specifically, it's just the current way how to configure repository rules. Therefore I'm asking for a way to configure repository rules from Bazel options.
Howdy all,
currently,
--action_envis affecting environment variables for Bazel actions, but also the environment for repository rules. Because of that it is possible to run Bazel asbazel build --action_env=CC=/usr/bin/clang //...when the user meansCC=/usr/bin/clang bazel build //.... Using--action_envis tempting, since it can be put into .bazelrc file and be a part of configs there, allowing you to have single flag build, e.g.bazel build --config=cuda //....The problem with that is that changing
--action_envinvalidates entire action graph when a environment variable changes, even though only one repository rule depended on the variable, it's output was the same, and change didn't need to be propagated further.I assume there are multiple possible solutions, my first guess would be to add a
--repo_envBazel option that only affected repository rules and not actions, but I'll leave this to experts.I'll also try to generalize the problem a bit - we don't need environment variables specifically, it's just the current way how to configure repository rules. Therefore I'm asking for a way to configure repository rules from Bazel options.