From d624955ee2d1ed1b75a5ef3786f871ee76801c1f Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 2 Aug 2016 20:46:42 -0700 Subject: [PATCH] Fix add_to_path/pyenv interaction in shellenv.sh --- dotfiles/lib/shellenv.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dotfiles/lib/shellenv.sh b/dotfiles/lib/shellenv.sh index 149bbf82..924556a8 100644 --- a/dotfiles/lib/shellenv.sh +++ b/dotfiles/lib/shellenv.sh @@ -8,8 +8,15 @@ function _source_shellenv_files { } function add_to_path { + local python_command local result - result=$($HOME/.lib/python/shell_path.py --include-assignment "$@") + + # We need to get a path to the ACTUAL python command because + # pyenv alters PATH before actually executing python, which ends + # up changing PATH in a way that is not desireable. + hash pyenv && python_command="$(pyenv which python)" || python_command="$(which python)" + + result=$($python_command $HOME/.lib/python/shell_path.py --include-assignment "$@") eval "$result" } @@ -53,7 +60,7 @@ function _python_setup { local PYENV_INIT_COMMANDS="$(pyenv init -)" eval "$PYENV_INIT_COMMANDS" else - echo "WARNING: pyenv is installed on this machine and python will likely not function correctly" + echo "WARNING: pyenv not is installed on this machine and python will likely not function correctly" fi # The following line is no longer necessary since the pyenv shim