Fix "version X is not installed" with multiple PYENV_VERSIONs

This was introduced when merging the rbenv upstream change
(https://github.com/sstephenson/rbenv/commit/6bb7f07d2d).
This commit is contained in:
Daniel Hahler 2014-10-16 02:51:07 +02:00
parent 8e657374a1
commit de5c61cd59
2 changed files with 20 additions and 4 deletions

View file

@ -45,7 +45,6 @@ for version in "${versions[@]}"; do
PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${version}/bin/${PYENV_COMMAND}" PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${version}/bin/${PYENV_COMMAND}"
fi fi
if [ -x "$PYENV_COMMAND_PATH" ]; then if [ -x "$PYENV_COMMAND_PATH" ]; then
PYENV_VERSION="$version"
break break
fi fi
done done
@ -59,10 +58,18 @@ done
if [ -x "$PYENV_COMMAND_PATH" ]; then if [ -x "$PYENV_COMMAND_PATH" ]; then
echo "$PYENV_COMMAND_PATH" echo "$PYENV_COMMAND_PATH"
elif ! [ -d "${PYENV_ROOT}/versions/${PYENV_VERSION}" ]; then
echo "pyenv: version \`$PYENV_VERSION' is not installed" >&2
exit 1
else else
for version in "${versions[@]}"; do
any_not_installed=0
if ! [ -d "${PYENV_ROOT}/versions/${version}" ]; then
echo "pyenv: version \`$version' is not installed" >&2
any_not_installed=1
fi
done
if [ "$any_not_installed" = 1 ]; then
exit 1
fi
echo "pyenv: $PYENV_COMMAND: command not found" >&2 echo "pyenv: $PYENV_COMMAND: command not found" >&2
versions="$(pyenv-whence "$PYENV_COMMAND" || true)" versions="$(pyenv-whence "$PYENV_COMMAND" || true)"

View file

@ -65,6 +65,15 @@ create_executable() {
assert_failure "pyenv: version \`3.3' is not installed" assert_failure "pyenv: version \`3.3' is not installed"
} }
@test "versions not installed" {
create_executable "3.4" "py.test"
PYENV_VERSION=2.7:3.3 run pyenv-which py.test
assert_failure <<OUT
pyenv: version \`2.7' is not installed
pyenv: version \`3.3' is not installed
OUT
}
@test "no executable found" { @test "no executable found" {
create_executable "2.7" "py.test" create_executable "2.7" "py.test"
PYENV_VERSION=2.7 run pyenv-which fab PYENV_VERSION=2.7 run pyenv-which fab