Skip to content

pyenv-win detection fails: looking for pyenv.exe instead of pyenv.bat #315

@karthiknadig

Description

@karthiknadig

Bug Description

On Windows, the pyenv locator fails to detect pyenv-win from PATH because it looks for pyenv.exe, but pyenv-win provides pyenv.bat instead.

Location

crates/pet-pyenv/src/environment_locations.rs in get_binary_from_known_paths():

pub fn get_binary_from_known_paths(env_vars: &EnvVariables) -> Option<PathBuf> {
    for known_path in &env_vars.known_global_search_locations {
        let exe = if cfg!(windows) {
            known_path.join("pyenv.exe")  // <-- BUG: should be pyenv.bat
        } else {
            known_path.join("pyenv")
        };
        if exe.is_file() {
            return Some(norm_case(exe));
        }
    }
    None
}

pyenv-win Actual Files

According to the pyenv-win repository, the bin/ folder contains:

  • pyenv.bat - Main Windows batch file
  • pyenv.ps1 - PowerShell script
  • pyenv - Shell script for cygwin/git-bash

There is no pyenv.exe file.

Expected Behavior

The code should look for pyenv.bat on Windows when searching PATH directories.

Suggested Fix

pub fn get_binary_from_known_paths(env_vars: &EnvVariables) -> Option<PathBuf> {
    for known_path in &env_vars.known_global_search_locations {
        if cfg!(windows) {
            // pyenv-win provides pyenv.bat, not pyenv.exe
            let exe = known_path.join("pyenv.bat");
            if exe.is_file() {
                return Some(norm_case(exe));
            }
        } else {
            let exe = known_path.join("pyenv");
            if exe.is_file() {
                return Some(norm_case(exe));
            }
        }
    }
    None
}

Related Issue

microsoft/vscode-python-environments#590

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIssue identified by VS Code Team member as probable bug

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions