Repository navigation
Description
Versions: rules_python 1.9.1 (the same line is in 2.5.0 and main; not run there), Bazel 8.4.2, macOS arm64, hermetic CPython 3.13.
What happens
python_repository ends with
rctx.delete("python")
rctx.symlink(python_bin, "python")rctx.symlink writes an absolute target, so the repo's python entry is
<output_base>/external/rules_python++python+python_3_13_<platform>/bin/python3.
Since python_repository returns rctx.repo_metadata(reproducible = True) when a sha256 is set, Bazel moves the repo into the repo contents cache (--repo_contents_cache) and shares it between output bases. The absolute link goes with it. Every output base that gets the cache hit then has a python that resolves into the output base that first fetched the repo.
Two consequences, both observed:
-
If that first output base no longer has the interpreter (it was deleted or expunged, or a fetch there was interrupted), every other output base fails in
host_compatible_python_repo:rules_python:host_compatible_python_repo(@@rules_python++python+python_3_13_host) FAIL: repo.execute: CheckHostInterpreter: end: failure: src/main/tools/process-wrapper-legacy.cc:80: "execvp(<output_base>/external/rules_python++python+python_3_13_host/python, ...)": No such file or directoryNothing is re-extracted, because the cache entry is valid as far as Bazel can tell.
-
If the first output base is later used with a different rules_python version that pins a different patch release, the other output bases silently run that interpreter as their host interpreter (we saw 3.13.9 where 3.13.13 was expected).
Reproduction
Two output bases A and B, one --repo_contents_cache directory, a workspace with a hermetic toolchain and any target that needs @python_3_13_host (a pip.parse hub is enough).
- In A:
bazel build --nobuild <target>.readlink <cache>/<entry>/1/pythonprints an absolute path into A. - Remove A (or interrupt a refetch of the interpreter repo there).
- In B:
bazel build --nobuild <target>fails with the error above.
5 of 5 for us. With the contents cache disabled, step 3 passes. With a single output base it cannot happen, because the link leads back into the same output base.
A fix that works for us
Make the link relative on platforms that have ln:
rctx.delete("python")
- rctx.symlink(python_bin, "python")
+ if "windows" in platform:
+ rctx.symlink(python_bin, "python")
+ else:
+ repo_utils.execute_checked(
+ rctx,
+ op = "python_repository.SymlinkPython",
+ arguments = ["ln", "-s", python_bin, "python"],
+ logger = logger,
+ )With it, 8 of 8 runs of the sequences above pass, no symlink in the cache points into an output base, and the host interpreter resolves into the cache entry. Windows is unchanged and untested. Another option would be for the repo not to declare itself reproducible while it contains an absolute link.
Activity
aignas commentedon Nov 13, 2026
I did look at it a little and it seems that bazel 9.0.1 and above may create the symlinks as relative: https://github.com/bazel-contrib/bazel_features/compare/v1.44.0...v1.45.0.patch
aignas commentedon Nov 14, 2026
Could you see if this is reproducible with 8.x of bazel? 8.4 is quite old.
aignas commentedon Nov 15, 2026
Could not reproduce:
--repo_contents_cache#3039