-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
--incompatible_strict_action_env breaks autodetecting Python toolchain on Mac #8536
Comments
Gerrit breakage tracked here. Note that their bazelrc contains
I'm not sure why |
|
IIRC Gerrit sets Related:
In a nutshell, after I have added action cache feature to Bazel in this CL, one of the most important features is to be able to build a project in different directory clones, re-using action cache (now called disk cache). That was not working. As pointed out by @ulfjack in this comment, adding |
@brandjon Would it be possible for python to detect the PATH to the interpret as a repository_rule? |
Yes, but we originally decided that wasn't necessary. Such a toolchain would only work for the host machine of course (notwithstanding running the repo rule in a docker image, etc.). Had I realized how much the action env could vary I might've chosen differently. I don't think we need to add a new toolchain at this time though. Users can migrate by either fiddling with the action_env (meh) or better yet defining an appropriate toolchain for the platform they're running on. In the case of our CI, maybe we need to adjust our buildkite runner to register an explicit Python toolchain. |
FTR, the rules_nodejs issue is fixed by adding I think that |
See discussion in #8425. It seems that |
In debugging the gerrit failure, I see that they're using a genrule-within-a-genrule. What's happening is that the outer genrule transitions to the host config for its tools, so the inner genrule itself (not just its tools) gets built in the host config. But the host config does not propagate To fix this, we need to do one of the following:
|
I'd like to do 1 or 2 and cherrypick into the release, so bumping priority. |
Thank you for debugging! We should definitely do 2 (it’s just wrong to not include /usr/local/bin) and probably also do 1, but that can be done afterwards. |
From #7816 (comment), you say it happens only when (I would vote for releasing 0.28 quickly, but no everyone seems to agree) |
To some extent people have been using The flag had previously been flipped on and rolled back. I don't know if anyone is actively working on trying to flip it again, and whether we have made a decision regarding supporting it. +@aehlig |
There was a long discussion on bazel-discuss about this and it was agreed upon that the whole idea of having a "strict PATH" that's valid for "any Linux installation" or "any Windows installation" is flawed and does not work. Thus, the flag and mechanism should go away, instead Bazel should simply use the PATH set by the user's shell. Users would then be able to override this either by using a Bazel wrapper that always runs Bazel with a fixed PATH, or by setting @buchgr also has some context and had some advanced ideas how to make it possible to achieve better cache hits without requiring a "strict PATH", AFAIR. |
Sounds like someone should own a bug for removing the flag then. Would there be an easy way to opt into an environment variable being unavailable by default, instead of inherited by default? |
I don’t understand - what do you mean with opt-in to an environment variable being unavailable by default? And what’s the relation to the above ideas how to fix this? |
Sorry, I was digressing away from this problem. I was wondering, if we're getting rid of the strict environment flag, but we're supporting Anyway, for this issue I'm working on a quick fix that implements 2. |
With this change, when --incompatible_strict_action_env is on but no override for PATH is available, the default PATH will include /usr/local/bin. This allows Python 3 to be on PATH on mac, which is important for the autodetecting Python toolchain. Without this change, users can still use --action_env=PATH[=...], but that doesn't work in all cases (e.g. genrules that are themselves built in the host config). Fixes #8536. Confirmed that this fixes the failure seen in https://bugs.chromium.org/p/gerrit/issues/detail?id=10953. RELNOTES: When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. PiperOrigin-RevId: 252696581
@brandjon I am trying to build gerrit@HEAD (7afb83f73b031b8e03cb905bc97b1a9ab79ddf0c) on Mac OS now, with Mojave 10.14.5 and seeing this breakage:
Update I tried to update Python on this machine, and the outcome was:
I am updating XCode version right now and will report the result later. Update2 XCode installed. Now, trying to install python with brew, I am getting this:
Now, after running python upgrade:
Gerrit can be built:
|
Yep, the error was because your machine didn't have Python 3 installed, and prior to 0.27 it worked because the default behavior effectively was to use Python 2 in spite of the way the gerrit codebase (and many others) are set up. Your options were to
|
This is needed to fix Bazel CI build breakage on Mac OS. See these issues for more details: [1], [2]. [1] bazelbuild/bazel#8536 [2] bazelbuild/continuous-integration#724 Change-Id: Ib879ccd375b19dc2e8d4d4e6e567629b7d35636d
With this change, when --incompatible_strict_action_env is on but no override for PATH is available, the default PATH will include /usr/local/bin. This allows Python 3 to be on PATH on mac, which is important for the autodetecting Python toolchain. Without this change, users can still use --action_env=PATH[=...], but that doesn't work in all cases (e.g. genrules that are themselves built in the host config). Fixes bazelbuild#8536. Confirmed that this fixes the failure seen in https://bugs.chromium.org/p/gerrit/issues/detail?id=10953. RELNOTES: When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. PiperOrigin-RevId: 252696581
With this change, when --incompatible_strict_action_env is on but no override for PATH is available, the default PATH will include /usr/local/bin. This allows Python 3 to be on PATH on mac, which is important for the autodetecting Python toolchain. Without this change, users can still use --action_env=PATH[=...], but that doesn't work in all cases (e.g. genrules that are themselves built in the host config). Fixes bazelbuild#8536. Confirmed that this fixes the failure seen in https://bugs.chromium.org/p/gerrit/issues/detail?id=10953. RELNOTES: When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. PiperOrigin-RevId: 252696581
With this change, when --incompatible_strict_action_env is on but no override for PATH is available, the default PATH will include /usr/local/bin. This allows Python 3 to be on PATH on mac, which is important for the autodetecting Python toolchain. Without this change, users can still use --action_env=PATH[=...], but that doesn't work in all cases (e.g. genrules that are themselves built in the host config). Fixes bazelbuild#8536. Confirmed that this fixes the failure seen in https://bugs.chromium.org/p/gerrit/issues/detail?id=10953. RELNOTES: When `--incompatible_strict_action_env` is enabled, the default `PATH` now includes `/usr/local/bin`. PiperOrigin-RevId: 252696581
This causes on issue on macOS because it ships with I submitted a non-ideal fix for this #9402 |
Enabling
--incompatible_strict_action_env
without providing an explicit--action_env
causesPATH
to default to/bin:/usr/bin
.bazel/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
Lines 169 to 171 in e495e6b
bazel/src/main/java/com/google/devtools/build/lib/bazel/rules/BazelRuleClassProvider.java
Lines 449 to 454 in e495e6b
On our Mac CI workers,
python3
is installed via Homebrew in/usr/local/bin
. I expect other Mac users would have similar configurations.This causes downstream failures in my presubmit to flip
--incompatible_use_python_toolchains
for Bazel 0.27. The flag is being flipped anyway. I expect those projects will have to either modify their--action_env
or somehow modify their buildkite CI to add a custom Python toolchain.+cc @philwo for CI, @buchgr for strict action env.
The text was updated successfully, but these errors were encountered: