You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Batch activation changes inherited PATH under delayed expansion #3617
With delayed expansion enabled in cmd.exe, activate.bat and deactivate.bat change an inherited PATH entry containing !name!. A Windows 11 check changed C:\Test!q!\bin to C:\Test\bin after activation and deactivation; with delayed expansion disabled, it preserved the entry.
Affected code
The batch activation template saves and prepends PATH. The deactivation template restores the saved value. These lines are also present at the report's commit, 8e09166ddfbdaed3a5dbccc216d38ff1d3dbb4c2.
Mechanism
The batch files insert %PATH% or %_OLD_VIRTUAL_PATH% into a set command. With delayed expansion enabled, cmd.exe interprets !q! in the inserted text as a variable reference. If q is unset, it removes those characters. The path comes from the invoking shell; it need not be the path of the environment whose batch scripts are running.
Reproduction
On Windows 11, create an environment from the source build at ebe06113f440731ab9c5bd6506a4793140532dc9 with CPython 3.14 and no seed packages. Run the following in PowerShell from the directory containing plainvenv:
Expected: both modes restore PATH=C:\Test!q!\bin;C:\Windows\System32 after deactivation.
Impact
The caller loses the original PATH entry after this activation and deactivation sequence. Reproducibility: moderate, because it requires Windows, delayed expansion, and an inherited value containing exclamation marks. Real-world exposure: unlikely, because delayed expansion is disabled by default and the inherited path must also contain !.
Activity
🐛 fix(batch): preserve PATH bangs
🐛 fix(batch): preserve PATH bangs
🐛 fix(batch): preserve PATH bangs
🐛 fix(batch): preserve PATH bangs
🐛 fix(batch): preserve ! in PATH