Repository navigation
🐛 fix(activation): undo a live activation before activate.bat saves values - #3245
Merged
gaborbernat merged 2 commits intoSep 17, 2026
Merged
Conversation
…alues activate.bat saves TCL_LIBRARY, TK_LIBRARY and PKG_CONFIG_PATH before replacing them, but unlike PATH and PYTHONHOME it never checks whether an activation is already in effect. Running it a second time without deactivating (the same environment again, or switching to another one) saved the first activation's values as the ones to restore. deactivate then left the environment's pkgconfig directory in PKG_CONFIG_PATH and its tcl/tk paths in TCL_LIBRARY/TK_LIBRARY, and a TCL_LIBRARY the user had set beforehand was lost. While active, PKG_CONFIG_PATH also collected one pkgconfig entry per activation. The bash and PowerShell scripts avoid this by running deactivate first. Do the same in batch, but only when _OLD_VIRTUAL_PATH shows a previous activation is still live, since deactivate.bat clears any variable it has no saved copy of. The batch activation test now also runs activating twice before deactivating.
gaborbernat
approved these changes
Sep 17, 2026
6 of 9 tasks
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.
Running
activate.bata second time without deactivating in between (the same environment again, or switching to another one) makesdeactivaterestore the wrong values.activate.batsavesTCL_LIBRARY,TK_LIBRARYandPKG_CONFIG_PATHevery time it runs. UnlikePATHandPYTHONHOME, it never checks whether an activation is already in effect, so the second run saves the first activation's values as the ones to put back. On currentmain:activate,activate,deactivatewithPKG_CONFIG_PATHunset, it's left as<venv>\lib\pkgconfig, and while active it holds one copy of that entry per activationTCL_LIBRARYbehindTCL_LIBRARY=C:\mineset beforehand, activating a tcl environment twice and deactivating leaves the environment's tcl path, andC:\mineis goneThe bash and PowerShell scripts avoid this by running deactivate before activating. This does the same in batch, but only when
_OLD_VIRTUAL_PATHshows a previous activation is still live, becausedeactivate.batclears any variable it has no saved copy of. PowerShell keeps its_OLD_*values as PowerShell variables and bash doesn't export them, so they can't leak into acmdstarted from those shells and trigger this by mistake.test_batchnow also runs every existing combination (prompt, tcl, user values set or unset) with the activation done twice. Putting the oldactivate.batback fails all 8 of the new cases; dropping the_OLD_VIRTUAL_PATHguard fails the 8 cases where the user already had values set. I also checked by hand that the prompt isn't doubled, nothing extra is echoed, and an environment path with spaces and parentheses works.tox -e fix)docs/changelogfolder