Skip to content

Build failure with --incompatible_use_python_toolchains #8414

@keith

Description

@keith

Description of the problem / feature request:

When using --incompatible_use_python_toolchains on macOS, the build fails because it can't find any pythons:

% bazel build //examples/... --incompatible_use_python_toolchains
Starting local Bazel server and connecting to it...
INFO: Analyzed 174 targets (64 packages loaded, 2442 targets configured).
INFO: Found 174 targets...
ERROR: /Users/ksmiley/dev/rules_apple/examples/multi_platform/Buttons/BUILD:72:1: StoryboardCompile examples/multi_platform/Buttons/Buttons-intermediates/Base.lproj_storyboardc/Main.storyboardc failed (Exit 1)
which: no python3 in ((null))
which: no python in ((null))
Error: The default python toolchain (@bazel_tools//tools/python:autodetecting_toolchain) was unable to locate a suitable Python interpreter on the target platform at execution time. Please register an appropriate Python toolchain. See the documentation for py_runtime_pair here:
https://github.com/bazelbuild/bazel/blob/master/tools/python/toolchain.bzl.
Failure reason: Cannot locate 'python3' or 'python' on the target platform's PATH, which is:
/usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
INFO: Elapsed time: 8.957s, Critical Path: 0.28s
INFO: 1 process: 1 darwin-sandbox.
FAILED: Build did NOT complete successfully

I believe that the issue here is that the calls to which in this script aren't receiving the PATH environment variable. I found 2 workarounds:

  1. Add export PATH above the first which call
  2. Switch to command -v instead of which, which is preferred since it is part of the POSIX standard where which is not https://github.com/koalaman/shellcheck/wiki/SC2230

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

In rules_apple run:

bazel build //examples/... --incompatible_use_python_toolchains

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

Metadata

Metadata

Assignees

Labels

P1I'll work on this now. (Assignee required)team-Rules-PythonNative rules for Pythontype: bug

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions