bazelbuild/bazel

Better docs around environment variables

Open

#14,692 创建于 2022年2月2日

在 GitHub 查看
 (3 评论) (0 反应) (0 负责人)Java (4,465 fork)batch import
P2help wantedteam-Documentationteam-Remote-Exectype: documentation (cleanup)

仓库指标

Star
 (25,384 star)
PR 合并指标
 (平均合并 22天 20小时) (30 天内合并 77 个 PR)

描述

Description of the problem / feature request:

Environment variable handling is under-documented.

After trial-and-error, this is my understanding;

  1. If --incompatible_strict_action_env (enabled by default) is disabled, then Bazel automatically passes PATH, LD_LIBRARY_PATH, and TMPDIR to actions that use use_default_shell_env.
  2. --action_env passes environment variables to actions for the target configuration that use use_default_shell_env.
  3. --host_action_env passes environment variables to actions for the exec configuration that use use_default_shell_env.
  4. If env and use_default_shell_env of ctx.actions are both used, the former is ignored.

Assuming these statements are correct, they ought to be documented.

In particular, the following facts are missing from current docs:

(a) use_default_shell_env is required to pass any CLI-configured vars to actions. (b) use_default_shell_env causes env to be ignored.


P.S. use_default_shell_env is an awkward name, because it actually has nothing to do with shells.

贡献者指南