Skip interpreters that are not found on query (#15315)

Closes https://github.com/astral-sh/uv/issues/12155

We already throw this error earlier if we cannot find the interpreter
c318e8860e/crates/uv-python/src/interpreter.rs (L1039)

Why the pyenv-win shim _exists_ but fails to run with a not found error
is beyond me. I think I'll take the incremental improvement here by just
ignoring it. We can try to support their shims later?

#15317 confirms the fix.
This commit is contained in:
Zanie Blue 2025-08-18 10:42:48 -05:00 committed by GitHub
parent 3d8c21284a
commit 00e888098f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -909,23 +909,26 @@ impl InterpreterInfo {
.arg("-c")
.arg(script)
.output()
.map_err(
|err| match err.raw_os_error().and_then(|code| u32::try_from(code).ok()) {
.map_err(|err| {
if err.kind() == io::ErrorKind::NotFound {
return Error::NotFound(interpreter.to_path_buf());
}
#[cfg(windows)]
if let Some(APPMODEL_ERROR_NO_PACKAGE | ERROR_CANT_ACCESS_FILE) =
err.raw_os_error().and_then(|code| u32::try_from(code).ok())
{
// These error codes are returned if the Python interpreter is a corrupt MSIX
// package, which we want to differentiate from a typical spawn failure.
#[cfg(windows)]
Some(APPMODEL_ERROR_NO_PACKAGE | ERROR_CANT_ACCESS_FILE) => {
Error::CorruptWindowsPackage {
path: interpreter.to_path_buf(),
err,
}
}
_ => Error::SpawnFailed {
return Error::CorruptWindowsPackage {
path: interpreter.to_path_buf(),
err,
},
},
)?;
};
}
Error::SpawnFailed {
path: interpreter.to_path_buf(),
err,
}
})?;
if !output.status.success() {
let stderr = String::from_utf8_lossy(&output.stderr).trim().to_string();