`$VIRTUAL_ENV/bin` is not prepended to `$PATH`
georgevreilly opened this issue · comments
Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.
Prerequisite
- Make sure your problem is not listed in the common build problems.
- Make sure no duplicated issue has already been reported in the pyenv-virtualenv issues. You should look in closed issues, too.
- Make sure you are not asking us to help solving your specific issue.
- GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
- Make sure your problem is not derived from packaging (e.g. Homebrew).
- Please refer to the package documentation for the installation issues, etc.
- Make sure your problem is not derived from other plugins.
- This repository is maintaining the
pyenv-virtualenv
plugin only. Please refrain from reporting issues of other plugins here.
- This repository is maintaining the
Description
- Platform information (e.g. Ubuntu Linux 20.04):
macOS 12.0.1
- OS architecture (e.g. amd64):
arm64
- pyenv version:
2.2.2
- pyenv-virtualenv version:
1.1.5
- Python version:
3.10.0
- virtualenv version (if installed):
- Please attach the debug log of a faulty Pyenv invocation as a gist
Problem
pyenv-virtualenv 1.1.5 does not update PATH
, unlike traditional virtualenv activation.
In other words, $VIRTUAL_ENV/bin
is not prepended to $PATH
.
System Python: can't import pudb
(as expected).
❯ python -c 'import pudb'
Traceback (most recent call last):
File "<string>", line 1, in <module>
ImportError: No module named pudb
~ on ☁️ (us-east-1)
I created venv310
with pyenv-virtualenv and did pip install pudb
.
Activate venv310
using the traditional method. PATH
is adjusted.
❯ source $PYENV_ROOT/versions/3.10.0/envs/venv310/bin/activate
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ python -c 'import pudb'
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ which pudb3
/Users/georgevreilly/.pyenv/versions/3.10.0/envs/venv310/bin/pudb3
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ echo "$PATH" | sed -e 's/:/\n/g' | grep pyenv
/Users/georgevreilly/.pyenv/versions/3.10.0/envs/venv310/bin
/opt/homebrew/Cellar/pyenv-virtualenv/1.1.5/shims
/Users/georgevreilly/.pyenv/shims
/Users/georgevreilly/.pyenv/bin
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ deactivate
~ on ☁️ (us-east-1)
Activate venv310
with pyenv-virtualenv
.
import pudb
works but PATH
is not adjusted.
❯ pyenv activate venv310
pyenv-virtualenv: prompt changing will be removed from future release. configure `export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior.
(venv310)
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ python -c 'import pudb'
(venv310)
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ which pudb3
pudb3 not found
(venv310)
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ echo "$PATH" | sed -e 's/:/\n/g' | grep pyenv
/opt/homebrew/Cellar/pyenv-virtualenv/1.1.5/shims
/Users/georgevreilly/.pyenv/shims
/Users/georgevreilly/.pyenv/bin
(venv310)
~ via 🐍 v3.10.0 (venv310) on ☁️ (us-east-1)
❯ pyenv deactivate
~ on ☁️ (us-east-1)
Looking at rbenv
, I discovered the which
and exec
commands. So pyenv which pudb3
and pyenv exec pudb3 -h
work with pyenv-virtualenv.
This is by design. Shims dynamically select the correct executable without the need to alter PATH.