19710a2d17d69dc0315465875c4becbf5e4ead38

Author
Terry <tmoschou@gmail.com>
Committer
GitHub <noreply@github.com>
Date

Message

fix(pyenv): do not warn if PYENV_ROOT is undefined (#10162)

Co-authored-by: Terry Moschou <terry.moschou@fivecast.com>

Diff

 1diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh
 2index 922df8ead8d73ea3c4627afb9a5e1fff406fdb69..d91b5daa7cb84da2c4684a8d86045acbc5aae8fa 100644
 3--- a/plugins/pyenv/pyenv.plugin.zsh
 4+++ b/plugins/pyenv/pyenv.plugin.zsh
 5@@ -62,14 +62,14 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
 6 fi
 7 
 8 if [[ $FOUND_PYENV -eq 1 ]]; then
 9-  # Setup $PYENV_ROOT if not already set
10   if [[ -z "$PYENV_ROOT" ]]; then
11+    # This is only for backwards compatibility with users that previously relied
12+    # on this plugin exporting it. pyenv itself does not require it to be exported
13     export PYENV_ROOT="$(pyenv root)"
14-    pyenv_config_warning 'missing $PYENV_ROOT'
15   fi
16 
17   # Add pyenv shims to $PATH if not already added
18-  if [[ -z "${path[(Re)$PYENV_ROOT/shims]}" ]]; then
19+  if [[ -z "${path[(Re)$(pyenv root)/shims]}" ]]; then
20     eval "$(pyenv init --path)"
21     pyenv_config_warning 'missing pyenv shims in $PATH'
22   fi
23@@ -78,7 +78,7 @@ if [[ $FOUND_PYENV -eq 1 ]]; then
24   eval "$(pyenv init - --no-rehash zsh)"
25 
26   # If pyenv-virtualenv exists, load it
27-  if [[ -d "$PYENV_ROOT/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
28+  if [[ -d "$(pyenv root)/plugins/pyenv-virtualenv" && "$ZSH_PYENV_VIRTUALENV" != false ]]; then
29     eval "$(pyenv virtualenv-init - zsh)"
30   fi
31