Skip to content

fix: recover cached venvs from dangling package symlinks - #4318

Open
sean0407 wants to merge 2 commits into
bazel-contrib:mainfrom
sean0407:fix/rules-python-4269-dangling-venv
Open

sean0407 wants to merge 2 commits into
bazel-contrib:mainfrom
sean0407:fix/rules-python-4269-dangling-venv

Conversation

@sean0407

Copy link
Copy Markdown

Summary

A persistent venv can retain a dangling package-directory symlink after the Python runtime changes. When initialization then creates a runtime file link beneath that path, os.makedirs(..., exist_ok=True) raises FileExistsError instead of recovering.

Remove the parent symlink only when it is confirmed dangling, then create the directory and the current runtime file link. Fixes #4269.

Checks

  • Before: the issue reproduction raised FileExistsError at the parent-directory creation in a credential-isolated sandbox.
  • After: cached_venv_replaces_dangling_package_symlink_test passed in the same isolated sandbox (1 test); it checks that the stale package link becomes a directory and the child link resolves to the current runfiles file.
  • git diff --check passed.

The focused run was on macOS. Windows execution, Bazel, and buildifier were not run.

AI assistance: OpenAI Codex assisted with the patch and regression test; Sean is the submitting author.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Windows: cached venv initialization fails on dangling package symlinks

2 participants