fix(pyenv): identify shims correctly
Some checks failed
Azure Static Web Apps CI/CD / Build and Deploy (push) Has been cancelled
Release / changelog (push) Has been cancelled
Release / artifacts (push) Has been cancelled
Release / msi (arm64) (push) Has been cancelled
Release / msi (x64) (push) Has been cancelled
Release / msi (x86) (push) Has been cancelled
Release / release (push) Has been cancelled

This commit is contained in:
Jan De Dobbeleer 2025-03-04 07:40:19 +01:00 committed by Jan De Dobbeleer
parent 58670c5a80
commit a66586da69
2 changed files with 9 additions and 4 deletions

View file

@ -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

View file

@ -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)
}