revert: do not use PYENV_ROOT when printing path to completions.

Homebrew installations have PYENV_ROOT set to `~/.pyenv`, while the
actual completion file resides in /home/linuxbrew/.linuxbrew/Cellar/pyenv/2.4.23/completions/pyenv.zsh

Thus, if you try to use `$PYENV_ROOT/completions/pyenv.${shell}`, the
completions file will not be found, since you are pointing to:

`~/.pyenv/completions/pyenv.zsh`

when the actual location is:

`/home/linuxbrew/.linuxbrew/Cellar/pyenv/2.4.23/completions/pyenv.zsh`

This problem is resolved by using the parent folder of the currently
executing file:

`/home/linuxbrew/.linuxbrew/Cellar/pyenv/2.4.23/libexec/pyenv-init`

which is

`/home/linuxbrew/.linuxbrew/Cellar/pyenv/2.4.23`

And then go to completions from there.

I don't like the fact that homebrew installations store some things in
`/home/linuxbrew/.linuxbrew/Cellar/pyenv/2.4.23/libexec/pyenv-init`

while stuff like `shims` and python versions are stored in `~/.pyenv`, but
that's how it currently is.
This commit is contained in:
Christian Fredrik Johnsen 2024-12-21 13:50:00 +01:00
parent c2554fc885
commit 2e1c756793

View File

@ -237,7 +237,7 @@ function print_env() {
}
function print_completion() {
completion="${PYENV_ROOT}/completions/pyenv.${shell}"
completion="${0%/*/*}/completions/pyenv.${shell}"
if [ -r "$completion" ]; then
echo "source '$completion'"
fi