Repository navigation
Replace activation script regexes with literal path swap - #40
Open
danielpops wants to merge 2 commits into
Open
danielpops wants to merge 2 commits into
danielpops wants to merge 2 commits into
Conversation
virtualenv 21.14.9 restructured the bash activate template again, so the per-line regexes added for 20.36.0 left the old path in three places. Relocated venvs then warn on every bash activation and fail to activate from zsh. activate.csh, activate.xsh and activate.nu were also missing updates. Since get_orig_path already finds the original path, replace every whole-path occurrence of it instead of matching template lines. Also cover activate.nu, add a regression test that no activate script keeps the old path, and run CI weekly so new virtualenv releases are caught. Co-Authored-By: Clanker Claude <dpopes@yelp.com>
Member
Author
|
@nurdann this might be a fix in case issues are caused by the import of virtualenv |
ubuntu-latest now resolves to ubuntu-26.04, which has no setup-python builds for 3.8/3.9. Pin each matrix entry to a runner that has its version, and disable fail-fast so one broken entry doesn't cancel the rest. Bump checkout and setup-python to v4/v5. Drop the exists() branch from the no-old-path test by globbing activate*, and mark the old-virtualenv skip as no cover. Co-Authored-By: Clanker Claude <dpopes@yelp.com>
nurdann
approved these changes
Nov 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
virtualenv 21.14.9 changed the bash
activatetemplate again (the firstifnow spans two lines), so the regexes from #36 stop matching and leave the old path behind. A relocated venv then warns on every bashsourceand fails to activate from zsh:Instead of matching each template line, swap every whole-path occurrence of the original path, which
get_orig_pathalready finds:Also:
activate.nutoACTIVATION_SCRIPTS(it was never rewritten)ubuntu-latestnow being 26.04, which has no setup-python 3.8/3.9 builds: each matrix entry picks its runner (3.8/3.9 on 24.04),fail-fast: false, checkout/setup-python bumped to v4/v5 (same approach as Fix test matrix for ubuntu-26.04 runners docker-custodian#73)Evidence
Relocating a venv built with virtualenv 21.14.12:
activate,activate.csh,activate.xsh,activate.nustill reference the old path. bash warnsVirtual environment directory <old> does not exist!, zsh exits 1.After: 0 files reference the old path. bash, zsh and sh all activate cleanly. A second run reports
Already up-to-date.Test suite:
test_verbose,test_update_activation_script[activate],[activate.csh])New regression test, which fails on main against 21.15.5:
Merge Danger
Door: two-way
Merging is cheap to revert. Publishing to PyPI is not (versions are immutable), so this PR doesn't bump the version.
Blast Radius: deploys
Every relocated venv's activate scripts go through this path.
update_activation_scriptnow takesorig_path. Onlyupdate_scriptscalls it internally, but direct importers would break. Not manually tested: activating relocated venvs in fish, csh, nu or xonsh (I only verified their scripts no longer contain the old path).✨ Created with help from Clanker Claude