Skip Python interpreters that cannot be queried with permission errors (#15685)

Closes https://github.com/astral-sh/uv/issues/15651
This commit is contained in:
Zanie Blue 2025-09-05 09:03:41 -05:00 committed by GitHub
parent 7dd035c555
commit e136a51f3d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 22 additions and 2 deletions

View File

@ -1013,6 +1013,13 @@ impl Error {
);
false
}
InterpreterError::PermissionDenied { path, err } => {
debug!(
"Skipping unexecutable interpreter at {} from {source}: {err}",
path.display()
);
false
}
InterpreterError::NotFound(path)
| InterpreterError::BrokenSymlink(BrokenSymlink { path, .. }) => {
// If the interpreter is from an active, valid virtual environment, we should

View File

@ -797,6 +797,12 @@ pub enum Error {
#[source]
err: io::Error,
},
#[error("Failed to query Python interpreter at `{path}`")]
PermissionDenied {
path: PathBuf,
#[source]
err: io::Error,
},
#[error("{0}")]
UnexpectedResponse(UnexpectedResponseError),
#[error("{0}")]
@ -911,8 +917,15 @@ impl InterpreterInfo {
.arg(script)
.output()
.map_err(|err| {
if err.kind() == io::ErrorKind::NotFound {
return Error::NotFound(interpreter.to_path_buf());
match err.kind() {
io::ErrorKind::NotFound => return Error::NotFound(interpreter.to_path_buf()),
io::ErrorKind::PermissionDenied => {
return Error::PermissionDenied {
path: interpreter.to_path_buf(),
err,
};
}
_ => {}
}
#[cfg(windows)]
if let Some(APPMODEL_ERROR_NO_PACKAGE | ERROR_CANT_ACCESS_FILE) =