Skip to content

Commit

Permalink
Fix venv re-population race. (Cherry-pick of pantsbuild#16931)
Browse files Browse the repository at this point in the history
There was a race in venv re-population due to a non-atomic `rm`, create
sequence. There was no real need for the `rm` and the create is atomic
on its own; so just remove the `rm` which was only attempting to guard
"corrupted" venvs in a slapdash way. Now the venv either exists or it
doesn't from the script point of view. If the venv exists but has been
tampered with, its execution will consistently fail until there is a
manual intervention removing the venv dir offline.

Fixes pantsbuild#14618
Fixes pantsbuild#16778

(cherry picked from commit cace851)
  • Loading branch information
jsirois committed Sep 20, 2022
1 parent 160411d commit e61985d
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/python/pants/backend/python/util_rules/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,8 +696,7 @@ def _create_venv_script(
# If the seeded venv has been removed from the PEX_ROOT, we re-seed from the original
# `--venv` mode PEX file.
if [ ! -e "${{target_venv_executable}}" ]; then
rm -rf "${{venv_dir}}" || true
if [ ! -e "${{venv_dir}}" ]; then
PEX_INTERPRETER=1 ${{execute_pex_args}} -c ''
fi
Expand Down

0 comments on commit e61985d

Please sign in to comment.