diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index d6b0d35..38091ee 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -96,8 +96,8 @@ fi venv="${versions}" if [ -n "${VIRTUAL_ENV}" ]; then - # exit as success if some virtualenv is already activated outside from pyenv-virtualenv - if [ -z "${PYENV_VIRTUAL_ENV}" ]; then + # exit as success if a non-pyenv virtualenv is active + if [[ -z $PYENV_VIRTUAL_ENV || $PYENV_VIRTUAL_ENV != "$VIRTUAL_ENV" ]]; then if [ -z "${FORCE}" ]; then if [ -z "${QUIET}" ]; then echo "pyenv-virtualenv: virtualenv \`${VIRTUAL_ENV}' is already activated" 1>&2 diff --git a/test/activate.bats b/test/activate.bats index 9c1fc67..8c1760a 100644 --- a/test/activate.bats +++ b/test/activate.bats @@ -439,6 +439,34 @@ EOS unstub pyenv-prefix } +@test "do nothing if a 3rd-party virtualenv is active" { + export PYENV_VIRTUALENV_INIT=1 + export VIRTUAL_ENV="${TMP}/venv-3rd-party" + unset PYENV_VIRTUAL_ENV + + PYENV_SHELL="bash" run pyenv-sh-activate "venv" + + assert_success + assert_output <