From fbd0abd3f7a8d386e9213d727bfff0b18e6ab01d Mon Sep 17 00:00:00 2001 From: Romwierz Date: Tue, 8 Sep 2026 12:05:04 +0200 Subject: [PATCH] check if multiple Python versions are selected and use the first one --- libexec/pyenv-exec | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/libexec/pyenv-exec b/libexec/pyenv-exec index 7b08b88e..6117d700 100755 --- a/libexec/pyenv-exec +++ b/libexec/pyenv-exec @@ -68,7 +68,18 @@ if [ "${PYENV_BIN_PATH#${PYENV_ROOT}}" != "${PYENV_BIN_PATH}" ]; then export PATH="${PYENV_BIN_PATH}:${PATH}" fi if [ -n "$MODIFY_ENV" ]; then - export PYTHONHOME="$(pyenv-prefix)" + # Check if multiple Python versions are selected + VERSIONS=$(pyenv-prefix) + if [[ "$VERSIONS" == *:* ]]; then + echo 'Warning: multiple Python versions are selected' + VERSION="${VERSIONS%%:*}" + echo "Using the first one available (${VERSION##*/})" + else + VERSION="$VERSIONS" + fi + + # Assign the correct version of PYTHONHOME + export PYTHONHOME="$VERSION" export LD_LIBRARY_PATH="${PYTHONHOME}/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" fi exec "$PYENV_COMMAND_PATH" "$@"