From 00e888098fb3854255e275e2dfdd6907f906dcb1 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Mon, 18 Aug 2025 10:42:48 -0500 Subject: [PATCH] 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 https://github.com/astral-sh/uv/blob/c318e8860e69077fdfe8fff7356985e684591b40/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. --- crates/uv-python/src/interpreter.rs | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/crates/uv-python/src/interpreter.rs b/crates/uv-python/src/interpreter.rs index 37b644f9f..15de1cb76 100644 --- a/crates/uv-python/src/interpreter.rs +++ b/crates/uv-python/src/interpreter.rs @@ -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();