From a66586da6936803367bcf9c86e784b7cb92925d2 Mon Sep 17 00:00:00 2001 From: Jan De Dobbeleer Date: Tue, 4 Mar 2025 07:40:19 +0100 Subject: [PATCH] fix(pyenv): identify shims correctly --- src/segments/language.go | 10 ++++++++-- src/segments/python.go | 3 +-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/segments/language.go b/src/segments/language.go index a64f430c86c3..d4e30bfe5410 100644 --- a/src/segments/language.go +++ b/src/segments/language.go @@ -222,12 +222,14 @@ func (l *language) setVersion() error { for _, command := range l.commands { versionStr, err := l.runCommand(command) if err != nil { + log.Error(err) lastError = err continue } version, err := command.parse(versionStr) if err != nil { + log.Error(err) lastError = fmt.Errorf("err parsing info from %s with %s", command.executable, versionStr) continue } @@ -271,8 +273,12 @@ func (l *language) runCommand(command *cmd) (string, error) { } versionStr, err := command.getVersion() - if err != nil || versionStr == "" { - return "", errors.New("cannot get version") + if err != nil { + return "", err + } + + if len(versionStr) == 0 { + return "", errors.New("no version found") } return versionStr, nil diff --git a/src/segments/python.go b/src/segments/python.go index 9b45a061603f..2bcecf3a3176 100644 --- a/src/segments/python.go +++ b/src/segments/python.go @@ -138,8 +138,7 @@ func (p *Python) pyenvVersion() (string, error) { } pyEnvRoot := p.env.Getenv("PYENV_ROOT") - // TODO: pyenv-win has this at $PYENV_ROOT/pyenv-win/shims - if cmdPath != filepath.Join(pyEnvRoot, "shims", "python") { + if !strings.HasPrefix(cmdPath, pyEnvRoot) { return "", fmt.Errorf("executable at %s is not a pyenv shim", cmdPath) }