mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-12 05:23:53 -05:00
Fix deactivation issue with system version
$ pyenv global system
$ pyenv shell venv
(venv) $ pyenv shell --unset
(venv) $ pyenv version
system (set by /home/yamashita/.pyenv/version)
(venv) $ pyenv which python
/home/yamashita/.pyenv/versions/venv/bin/python # <-- should be `/usr/bin/python` (system)
This commit is contained in:
@@ -66,8 +66,10 @@ case "$shell" in
|
|||||||
bash )
|
bash )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
_pyenv_virtualenv_hook() {
|
_pyenv_virtualenv_hook() {
|
||||||
if [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
|
if [[ "\$(pyenv version-name)" == "system" ]]; then
|
||||||
pyenv deactivate;
|
pyenv deactivate || true;
|
||||||
|
elif [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
|
||||||
|
pyenv deactivate || true;
|
||||||
pyenv activate 2>/dev/null || true
|
pyenv activate 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
};
|
};
|
||||||
@@ -79,8 +81,10 @@ EOS
|
|||||||
fish )
|
fish )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
function _pyenv_virtualenv_hook --on-event fish_prompt;
|
||||||
if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
|
if [ (pyenv version-name) = "system" ]
|
||||||
eval (pyenv sh-deactivate)
|
eval (pyenv sh-deactivate); or true
|
||||||
|
else if [ "\$VIRTUAL_ENV" != (pyenv prefix) ]
|
||||||
|
eval (pyenv sh-deactivate); or true
|
||||||
eval (pyenv sh-activate 2>/dev/null); or true
|
eval (pyenv sh-activate 2>/dev/null); or true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -89,8 +93,10 @@ EOS
|
|||||||
zsh )
|
zsh )
|
||||||
cat <<EOS
|
cat <<EOS
|
||||||
_pyenv_virtualenv_hook() {
|
_pyenv_virtualenv_hook() {
|
||||||
if [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
|
if [[ "\$(pyenv version-name)" == "system" ]]; then
|
||||||
pyenv deactivate
|
pyenv deactivate || true
|
||||||
|
elif [[ "\$VIRTUAL_ENV" != "\$(pyenv prefix)" ]]; then
|
||||||
|
pyenv deactivate || true
|
||||||
pyenv activate 2>/dev/null || true
|
pyenv activate 2>/dev/null || true
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user