Prerequisite
Describe the bug
In v1.3.0, pyenv virtualenv-init generates shell hook code that uses bash array syntax, which is incompatible with POSIX /bin/sh. This causes scripts running with #!/bin/sh to fail with:
sh: 25: eval: Syntax error: "(" unexpected (expecting "}")
Exit code: 2
Reproduction steps
# On a system with /bin/sh (dash)
sh -c "$(pyenv virtualenv-init -)"
# OR run via any hook/script using #!/bin/sh
eval "$(pyenv virtualenv-init -)"
Likely cause
Commit 72cb35b ("Drastically speed up precommand hook by caching active version") introduced a performance optimization using bash arrays:
local -a _PYENV_VH_PATHS=()
_PYENV_VH_PATHS+=("/path/to/file")
"${_PYENV_VH_PATHS[@]}"
These constructs are not POSIX-compliant and fail when the shell is /bin/sh (dash).
Diagnostic details
Prerequisite
pyenv-virtualenvplugin only. Please refrain from reporting issues of other plugins here.Describe the bug
In v1.3.0,
pyenv virtualenv-initgenerates shell hook code that uses bash array syntax, which is incompatible with POSIX/bin/sh. This causes scripts running with#!/bin/shto fail with:Exit code: 2
Reproduction steps
Likely cause
Commit 72cb35b ("Drastically speed up precommand hook by caching active version") introduced a performance optimization using bash arrays:
These constructs are not POSIX-compliant and fail when the shell is
/bin/sh(dash).Diagnostic details
PYENV_DEBUG=1, e.g.env PYENV_DEBUG=1 pyenv install -v 3.6.4