bazel-skylib icon indicating copy to clipboard operation
bazel-skylib copied to clipboard

add use_default_shell_env attribute to run_binary

Open crt-31 opened this issue 9 months ago • 2 comments

run_binary should not inherit the default_shell_env by default, or at least have an option to not inherit them..

Currently, when run_binary calls ctx.actions.run it is hardcoded that it inherits the 'default shell env'. This causes unnecessary hermeticity issues.

https://github.com/bazelbuild/bazel-skylib/blob/25a8e9d60687fee887e54dcb9560ef08777235de/rules/run_binary.bzl#L52

My suggestion is to add use_default_shell_env to the run_binary_rule so the caller can set it to false. I'd even say that it should default to False (because my opinion is that Bazel stuff should default to hermeticity).

crt-31 avatar Apr 04 '25 22:04 crt-31

you should probably solve this with --incompatible_strict_action_env or something similar. removing this would remove --action_env values from the run, which is likely unexpected

keith avatar Apr 04 '25 23:04 keith

you should probably solve this with --incompatible_strict_action_env or something similar

I am using --incompatible_strict_action_env. My request is more about having the option to set use_default_shell_env to run_binary.

I am looking at run_binary() as similar to ctx.actions.run(). Since ctx.actions.run has use_default_shell_env attribute, it would be nice to add it to the run_binary(). There are cases where the default_shell_env is not desirable (particularly on Windows).

crt-31 avatar Apr 08 '25 18:04 crt-31