Skip to content

Commit fe45faa

Browse files
authored
fix(toolchains): Add Xcode repo env vars to local_runtime_repo for better cache invalidation (#3203)
On macOS, if one writes a `local_runtime_repo` with `interpreter_path = "/usr/bin/python3"`, the path to python3 inside the selected _Xcode.app/Contents/Developer_ directory gets cached. If a developer changes that directory with `xcode-select --switch` that cached file with the old directory remains. Making the local_runtime_repo rule sensitive to DEVELOPER_DIR and XCODE_VERSION (two conventionally adopted env vars among the Bazel + Apple ecosystem) will ensure that if Xcode changes, so will the resolved python3 path. Fixes #3123
1 parent 563c585 commit fe45faa

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,9 @@ END_UNRELEASED_TEMPLATE
8686

8787
{#v0-0-0-fixed}
8888
### Fixed
89+
* (toolchains) `local_runtime_repo` now respects changes to the `DEVELOPER_DIR` and `XCODE_VERSION`
90+
repo env vars, fixing stale cache issues on macOS with system (i.e. Xcode-supplied) Python
91+
([#3123](https://github.com/bazel-contrib/rules_python/issues/3123)).
8992
* (pypi) Fixes an issue where builds using a `bazel vendor` vendor directory
9093
would fail if the constraints file contained environment markers. Fixes
9194
[#2996](https://github.com/bazel-contrib/rules_python/issues/2996).

python/private/local_runtime_repo.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ How to handle errors when trying to automatically determine settings.
232232
),
233233
"_rule_name": attr.string(default = "local_runtime_repo"),
234234
},
235-
environ = ["PATH", REPO_DEBUG_ENV_VAR],
235+
environ = ["PATH", REPO_DEBUG_ENV_VAR, "DEVELOPER_DIR", "XCODE_VERSION"],
236236
)
237237

238238
def _expand_incompatible_template():

0 commit comments

Comments
 (0)