Skip to content

🐛 fix(activate): keep Git Bash PATH after cmd - #3669

Merged
gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/3638-bash-cross-shell-path
Nov 20, 2026
Merged

gaborbernat merged 1 commit into
pypa:mainfrom
gaborbernat:fix/3638-bash-cross-shell-path

Conversation

@gaborbernat

@gaborbernat gaborbernat commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

When batch activation saves a Windows PATH backup, Git Bash inherits it as _OLD_VIRTUAL_PATH. Bash activation then restores that backup before setting its own PATH, leaving a semicolon-separated Windows list where Bash expects a colon-separated list. Commands such as uname and basename cannot be found. The Bash activation script now keeps Git Bash's PATH during this handoff. Fixes #3638.

Batch backup crossed into Git Bash

The batch script exports its saved PATH to child processes. A new Git Bash session has no deactivate function from a prior Bash activation, so the Bash script discards the inherited backup before its initial cleanup. A Bash session that already has a deactivate function keeps its own backup for reactivation. The Windows integration test starts in cmd.exe, calls batch activation, launches Git Bash, and checks command lookup and PATH after Bash deactivation.

Behavior changes

Git Bash can activate after batch activation without losing command lookup, and Bash deactivation restores the PATH Git Bash had on entry. Existing batch activation and same-shell Bash reactivation keep their PATH restoration behavior. This does not change other environment variables inherited from cmd.exe.

Reported by oss-scanner: ANT-2026-R2DNTJGS.

@gaborbernat
gaborbernat force-pushed the fix/3638-bash-cross-shell-path branch 4 times, most recently from fd90491 to cf52fa3 Compare November 20, 2026 09:11
Discard a batch PATH backup when activation starts in a new Bash shell.
Keep Bash's own backup when activating again in the same shell.

Fixes pypa#3638
@gaborbernat
gaborbernat force-pushed the fix/3638-bash-cross-shell-path branch from cf52fa3 to bac953c Compare November 20, 2026 10:45
@gaborbernat
gaborbernat marked this pull request as ready for review November 20, 2026 12:03
@gaborbernat
gaborbernat merged commit 72fdab1 into pypa:main Nov 20, 2026
91 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bash activation restores Windows PATH inherited from batch

1 participant