-
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
Build failure with --incompatible_use_python_toolchains #8414
Comments
This fixes an issue on macOS where `which` failed to return any results because the `PATH` wasn't propagated. `command` is more standard for this use case as well https://github.com/koalaman/shellcheck/wiki/SC2230 Fixes bazelbuild#8414
Very nice, thanks for the diagnosis! I actually have been debugging this very issue in bazelbuild/continuous-integration#578. I have an in-flight PR to fix it that uses the I'll go ahead with my commit since it includes a regression test, then merge yours on top with minor modifications. |
This fixes an issue on macOS where `which` failed to return any results because the `PATH` wasn't propagated. `command` is more standard for this use case as well https://github.com/koalaman/shellcheck/wiki/SC2230 Fixes bazelbuild#8414
This fixes an issue on macOS where `which` failed to return any results because the `PATH` wasn't propagated. `command` is more standard for this use case as well https://github.com/koalaman/shellcheck/wiki/SC2230 Fixes bazelbuild#8414
Fixed by 7f49531 as well |
FYI I am doubting my understanding of PATH being unset a little bit. If PATH really is unset by Bazel when executing a |
@brandjon I think that works because it ends up falling back to the default |
I think I've verified this with a simple script:
Where the script is:
Or with a python script:
The first print here has nothing, but the second makes it clear it's using the macOS system python, not the ones earlier in my real PATH |
I had been assuming it was the shell itself that detected when So I wonder what it is that's initializing that environment. The OS itself (kernel + standard c library), as the user's default |
This is a modification of PR #8415, which changed `which` to `command -v` so it works when PATH isn't exported. `command` is more standard for this kind of use case (https://github.com/koalaman/shellcheck/wiki/SC2230). Unfortunately, `command -v` doesn't check the executable bit, so it's not as useful for us. The previous fix for this issue (7f49531) was based on exporting PATH, but this changes the environment seen by the exec'd payload Python code. The solution in this commit is to not export PATH but rather explicitly pass it to each invocation of `which`. Fixes #8414. See also bazelbuild/continuous-integration#578. Closes #8415. PiperOrigin-RevId: 249334274
This is a modification of PR #8415, which changed `which` to `command -v` so it works when PATH isn't exported. `command` is more standard for this kind of use case (https://github.com/koalaman/shellcheck/wiki/SC2230). Unfortunately, `command -v` doesn't check the executable bit, so it's not as useful for us. The previous fix for this issue (7f49531) was based on exporting PATH, but this changes the environment seen by the exec'd payload Python code. The solution in this commit is to not export PATH but rather explicitly pass it to each invocation of `which`. Fixes #8414. See also bazelbuild/continuous-integration#578. Closes #8415. PiperOrigin-RevId: 249334274
This is a modification of PR #8415, which changed `which` to `command -v` so it works when PATH isn't exported. `command` is more standard for this kind of use case (https://github.com/koalaman/shellcheck/wiki/SC2230). Unfortunately, `command -v` doesn't check the executable bit, so it's not as useful for us. The previous fix for this issue (7f49531) was based on exporting PATH, but this changes the environment seen by the exec'd payload Python code. The solution in this commit is to not export PATH but rather explicitly pass it to each invocation of `which`. Fixes #8414. See also bazelbuild/continuous-integration#578. Closes #8415. PiperOrigin-RevId: 249334274
This is a modification of PR bazelbuild#8415, which changed `which` to `command -v` so it works when PATH isn't exported. `command` is more standard for this kind of use case (https://github.com/koalaman/shellcheck/wiki/SC2230). Unfortunately, `command -v` doesn't check the executable bit, so it's not as useful for us. The previous fix for this issue (bazelbuild@7f49531) was based on exporting PATH, but this changes the environment seen by the exec'd payload Python code. The solution in this commit is to not export PATH but rather explicitly pass it to each invocation of `which`. Fixes bazelbuild#8414. See also bazelbuild/continuous-integration#578. Closes bazelbuild#8415. PiperOrigin-RevId: 249334274
Description of the problem / feature request:
When using
--incompatible_use_python_toolchains
on macOS, the build fails because it can't find any pythons:I believe that the issue here is that the calls to
which
in this script aren't receiving thePATH
environment variable. I found 2 workarounds:export PATH
above the firstwhich call
command -v
instead ofwhich
, which is preferred since it is part of the POSIX standard where which is not https://github.com/koalaman/shellcheck/wiki/SC2230Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
In
rules_apple
run:What operating system are you running Bazel on?
macOS
What's the output of
bazel info release
?release 0.25.0
Have you found anything relevant by searching the web?
Nothing helpful on #7899
The text was updated successfully, but these errors were encountered: