Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
O
oh-my-zsh
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
github
oh-my-zsh
Commits
c08fb77c
Unverified
Commit
c08fb77c
authored
Sep 03, 2021
by
Marc Cornellà
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(pyenv): properly load pyenv shims and warn of broken configuration
Closes #10133 Co-authored-by:
Chloé “Matcha”
<
chloe.desoutter@gmail.com
>
parent
53b54f5f
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
15 deletions
+33
-15
pyenv.plugin.zsh
plugins/pyenv/pyenv.plugin.zsh
+33
-15
No files found.
plugins/pyenv/pyenv.plugin.zsh
View file @
c08fb77c
pyenv_config_warning
()
{
local
reason
=
"
$1
"
local
pyenv_root
=
"
${
PYENV_ROOT
/#
$HOME
/\
$HOME
}
"
cat
>
&2
<<
EOF
Found pyenv, but it is badly configured (
$reason
). pyenv might not
work correctly for non-interactive shells (for example, when run from a script).
${
(%)
:-
"%B%F{yellow}"
}
To fix this message, add these lines to the '.profile' and '.zprofile' files
in your home directory:
${
(%)
:-
"%f"
}
export PYENV_ROOT="
$pyenv_root
"
export PATH="\
$PYENV_ROOT
/bin:\
$PATH
"
eval "\
$(
pyenv init
--path
)
"
${
(%)
:-
"%F{yellow}"
}
You'll need to restart your user session for the changes to take effect.
${
(%)
:-
%b%f
}
For more information go to https://github.com/pyenv/pyenv/#installation.
EOF
}
# This plugin loads pyenv into the current shell and provides prompt info via
# This plugin loads pyenv into the current shell and provides prompt info via
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
# the 'pyenv_prompt_info' function. Also loads pyenv-virtualenv if available.
...
@@ -30,35 +49,33 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
...
@@ -30,35 +49,33 @@ if [[ $FOUND_PYENV -ne 1 ]]; then
# If we found pyenv, load it but show a caveat about non-interactive shells
# If we found pyenv, load it but show a caveat about non-interactive shells
if
[[
$FOUND_PYENV
-eq
1
]]
;
then
if
[[
$FOUND_PYENV
-eq
1
]]
;
then
cat
>
&2
<<
EOF
Found pyenv, but it is badly configured. pyenv might not work for
non-interactive shells (for example, when run from a script).
${
bold_color
}
To fix this message, add these lines to the '.profile' and '.zprofile' files
in your home directory:
export PYENV_ROOT="
${
dir
/#
$HOME
/\
$HOME
}
"
export PATH="\
$PYENV_ROOT
/bin:\
$PATH
"
eval "\
$(
pyenv init
--path
)
"
You'll need to restart your user session for the changes to take effect.
${
reset_color
}
For more info go to https://github.com/pyenv/pyenv/#installation.
EOF
# Configuring in .zshrc only makes pyenv available for interactive shells
# Configuring in .zshrc only makes pyenv available for interactive shells
export
PYENV_ROOT
=
"
$dir
"
export
PYENV_ROOT
=
"
$dir
"
export
PATH
=
"
$PYENV_ROOT
/bin:
$PATH
"
export
PATH
=
"
$PYENV_ROOT
/bin:
$PATH
"
eval
"
$(
pyenv init
--path
)
"
eval
"
$(
pyenv init
--path
)
"
# Show warning due to bad pyenv configuration
pyenv_config_warning
'pyenv command not found in $PATH'
fi
fi
fi
fi
if
[[
$FOUND_PYENV
-eq
1
]]
;
then
if
[[
$FOUND_PYENV
-eq
1
]]
;
then
# Setup $PYENV_ROOT if not already set
if
[[
-z
"
$PYENV_ROOT
"
]]
;
then
if
[[
-z
"
$PYENV_ROOT
"
]]
;
then
export
PYENV_ROOT
=
"
$(
pyenv root
)
"
export
PYENV_ROOT
=
"
$(
pyenv root
)
"
pyenv_config_warning
'missing $PYENV_ROOT'
fi
# Add pyenv shims to $PATH if not already added
if
[[
-z
"
${
path
[(Re)
$PYENV_ROOT
/shims]
}
"
]]
;
then
eval
"
$(
pyenv init
--path
)
"
pyenv_config_warning
'missing pyenv shims in $PATH'
fi
fi
# Load pyenv
eval
"
$(
pyenv init -
--no-rehash
zsh
)
"
eval
"
$(
pyenv init -
--no-rehash
zsh
)
"
# If pyenv-virtualenv exists, load it
if
[[
-d
"
$PYENV_ROOT
/plugins/pyenv-virtualenv"
]]
;
then
if
[[
-d
"
$PYENV_ROOT
/plugins/pyenv-virtualenv"
]]
;
then
eval
"
$(
pyenv virtualenv-init - zsh
)
"
eval
"
$(
pyenv virtualenv-init - zsh
)
"
fi
fi
...
@@ -74,3 +91,4 @@ else
...
@@ -74,3 +91,4 @@ else
fi
fi
unset
FOUND_PYENV pyenvdirs
dir
unset
FOUND_PYENV pyenvdirs
dir
unfunction pyenv_config_warning
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment