[PATCH] D109873: Add use_default_shell_env = True to ctx.actions.run

Geoffrey Martin-Noble via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 16 16:25:26 PDT 2021


GMNGeoffrey added a comment.

I've done quite a bit of hunting around and reading about `default_shell_env` (why wasn't this in the documentation at https://docs.bazel.build/versions/main/skylark/lib/actions.html#run.use_default_shell_env?). From my reading, it appears that `use_default_shell_env` will include the entire local shell environment as part of each Bazel invocation. This has implications for build hermeticness and especially for shared caching, so I'm a bit reluctant to do it. AFAICT if you set `--action_env=LD_LIBRARY_PATH` and `--host_action_env=LD_LIBRARY_PATH` then actions (in target and host configuration, respectively) *should* have the `LD_LIBRARY_PATH` in their env. That's a decision that can be made in a more localized way so that individual users/projects can make their own tradeoff between hermeticness and actually getting their build to work :-P Following the thread on https://github.com/bazelbuild/bazel/issues/12579 and https://github.com/tensorflow/tensorflow/pull/44549 it seems that `--host_action_env` is broken and was fixed by https://github.com/bazelbuild/bazel/commit/e6670825b1 and then, if I'm reading GitHub UI's correctly, backported to the 4.x LTS release with https://github.com/bazelbuild/bazel/commit/80cf90e51a. Further, I believe that `--incompatible_strict_action_env` means that the default shell env *doesn't* inherit `PATH`, `LD_LIBRARY_PATH`, etc, so there is still a way to recover the more cache-friendly and hermetic behavior. I'm actually not sure in that case what the `default_shell_env` *does* contain and what shell env the action gets if not the default one. None, I guess? So still some confusion there.

So to evaluate the best path forward, could you try out whether building with Bazel 4.2 and `--host_action_env=LD_LIBRARY_PATH` fixes the issue for you? I'll also do a bit more investigation of what's going on with `default_shell_env`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109873/new/

https://reviews.llvm.org/D109873



More information about the llvm-commits mailing list