From ac56c313df61dc1fc7667b41d9fb04eb34224c8e Mon Sep 17 00:00:00 2001 From: Dave Borowitz Date: Mon, 16 Apr 2018 12:05:38 +0200 Subject: [PATCH] bazel: Recommend setting --action_env=PATH for local cache The old configuration makes it impossible to compile Gerrit on Mac with recent versions of Bazel. The flag --experimental_strict_action_env now makes Bazel pass PATH=/bin:/usr/bin to subcommands. Building PolyGerrit requires using node from $PATH. On Macs it is impossible (even for root) to write to /usr/bin, so node has to live somewhere not in that hard-coded PATH. I'm not sure when this behavior changed in Bazel; it seems like it should have broken long ago. But it's marked experimental so we can't complain too much. The documentation of this option says: If true, Bazel uses an environment with a static value for PATH and does not inherit LD_LIBRARY_PATH or TMPDIR. Use --action_env=ENV_VARIABLE if you want to inherit specific environment variables from the client, but note that doing so can prevent cross-user caching if a shared cache is used. Passing --action_env=PATH fixes the problem. I think it should be safe(ish) to pass --action_env=PATH, since the particular setup described in our docs is not used for cross-user caching. This may not catch potential cache invalidations due to different versions of tools, but I don't see how it's any worse than when the binaries in /usr/bin get updated. Change-Id: I94543bd4801b83a66ff150baf3fb9e12ded7555f --- Documentation/dev-bazel.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/dev-bazel.txt b/Documentation/dev-bazel.txt index 3e52f16618..34e1fd879f 100644 --- a/Documentation/dev-bazel.txt +++ b/Documentation/dev-bazel.txt @@ -390,6 +390,7 @@ and add these lines to your `~/.bazelrc` file: build --experimental_local_disk_cache_path=/home//.gerritcodereview/bazel-cache/cas build --experimental_local_disk_cache build --experimental_strict_action_env +build --action_env=PATH ---- [NOTE] `experimental_local_disk_cache_path` must be absolute path. Expansion of `~` is