Skip to content

🐛 fix(activation): silence deactivate hash -r under set -e#3152

Merged
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:sync
May 31, 2026
Merged

🐛 fix(activation): silence deactivate hash -r under set -e#3152
gaborbernat merged 2 commits into
pypa:mainfrom
gaborbernat:sync

Conversation

@gaborbernat

Copy link
Copy Markdown
Contributor

Sourcing the bash/zsh activation script and later running deactivate could abort the shell when strict mode is on. 🐚 Under set -euo pipefail with shell command hashing disabled (set +h), the hash -r call inside deactivate() returns non-zero, and 2>/dev/null only hides its stderr, not its exit status, so the failing command tears down the session.

The deactivate() call now appends || true, the same guard the trailing activation-time hash -r already carried. This brings the two hash -r sites into line and mirrors the equivalent CPython venv change in gh-149701.

The fix is confined to the bash/zsh activator; behavior under non-strict shells is unchanged since hash -r already succeeded there.

The deactivate() hash -r call lacked the || true guard the trailing
activation call already had, so deactivate could abort under
set -euo pipefail with shell hashing disabled. Matches CPython venv
gh-149701.
@gaborbernat gaborbernat merged commit b724203 into pypa:main May 31, 2026
58 checks passed
@gaborbernat gaborbernat deleted the sync branch May 31, 2026 16:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1 participant