Skip to main content

resolve_program

Function resolve_program 

Source
pub fn resolve_program(program: &str) -> String
Expand description

Resolve a program name into something Command::new can actually spawn.

On Windows the JS package managers (npm, pnpm, yarn, bun) are shipped as .cmd shims. CreateProcess only ever appends .exe, so Command::new("npm") fails with NotFound even when npm is installed and on PATH. Search PATH ourselves for the shim extensions and hand back the full path.

Names that already contain a path separator (e.g. .venv\Scripts\python.exe) are returned unchanged, as are all names on non-Windows platforms.