mirror of
https://github.com/pyenv/pyenv.git
synced 2025-11-14 14:23:53 -05:00
pyenv-exec: no -a with exec to keep $PATH with system version (#1169)
Using `exec -a` caused Python to use $PATH to look up the full program name (for
`sys.executable`), which 314937d then tried to fix by changing $PATH
also for the system version.
This is not necessary anymore when not using the short name with `exec`.
This was rejected upstream
(https://github.com/rbenv/rbenv/pull/1089#issuecomment-394531896), since
it is not a problem with Ruby apparently.
Uses $PYENV_ROOT to check if system version is used.
Fixes https://github.com/pyenv/pyenv/issues/98.
Fixes https://github.com/pyenv/pyenv/issues/789.
This commit is contained in:
@@ -41,7 +41,8 @@ for script in "${scripts[@]}"; do
|
||||
done
|
||||
|
||||
shift 1
|
||||
# CPython's `sys.executable` requires the `PYENV_BIN_PATH` to be at the top of the `PATH`.
|
||||
# https://github.com/pyenv/pyenv/issues/98
|
||||
export PATH="${PYENV_BIN_PATH}:${PATH}"
|
||||
exec -a "$PYENV_COMMAND" "$PYENV_COMMAND_PATH" "$@"
|
||||
if [ "${PYENV_BIN_PATH#${PYENV_ROOT}}" != "${PYENV_BIN_PATH}" ]; then
|
||||
# Only add to $PATH for non-system version.
|
||||
export PATH="${PYENV_BIN_PATH}:${PATH}"
|
||||
fi
|
||||
exec "$PYENV_COMMAND_PATH" "$@"
|
||||
|
||||
Reference in New Issue
Block a user