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

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.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2 files changed
tree: bc8afbdf131e517bf33aece6fc71b8bec6a2cee5
  1. .github/
  2. docs/
  3. src/
  4. tasks/
  5. tests/
  6. .dockerignore
  7. .gitattributes
  8. .gitignore
  9. .markdownlint.yaml
  10. .pre-commit-config.yaml
  11. .readthedocs.yml
  12. LICENSE
  13. pyproject.toml
  14. README.md
  15. tox.toml
README.md

virtualenv

PyPI PyPI - Implementation PyPI - Python Version Documentation Discord Downloads PyPI - License check

A tool for creating isolated virtual python environments.

Code of Conduct

Everyone interacting in the virtualenv project's codebases, issue trackers, chat rooms, and mailing lists is expected to follow the PSF Code of Conduct.