diff --git a/crates/uv-python/src/discovery.rs b/crates/uv-python/src/discovery.rs index a90b26d65..155455ff9 100644 --- a/crates/uv-python/src/discovery.rs +++ b/crates/uv-python/src/discovery.rs @@ -222,8 +222,9 @@ pub enum Error { PythonSource, ), - /// An error was encountered when interacting with a managed Python installation. - #[error(transparent)] + /// An error was encountered while trying to find a managed Python installation matching the + /// current platform. + #[error("Failed to discover managed Python installations")] ManagedPython(#[from] crate::managed::Error), /// An error was encountered when inspecting a virtual environment. diff --git a/crates/uv-python/src/downloads.rs b/crates/uv-python/src/downloads.rs index 57dafd8db..0659892d1 100644 --- a/crates/uv-python/src/downloads.rs +++ b/crates/uv-python/src/downloads.rs @@ -91,7 +91,7 @@ pub enum Error { NoDownloadFound(PythonDownloadRequest), #[error("A mirror was provided via `{0}`, but the URL does not match the expected format: {0}")] Mirror(&'static str, &'static str), - #[error(transparent)] + #[error("Failed to determine the libc used on the current platform")] LibcDetection(#[from] LibcDetectionError), #[error("Remote Python downloads JSON is not yet supported, please use a local path")] RemoteJSONNotSupported, diff --git a/crates/uv-python/src/libc.rs b/crates/uv-python/src/libc.rs index a7c427bad..40950ae08 100644 --- a/crates/uv-python/src/libc.rs +++ b/crates/uv-python/src/libc.rs @@ -37,6 +37,8 @@ pub enum LibcDetectionError { InvalidLdSoOutputMusl(PathBuf), #[error("Could not read ELF interpreter from any of the following paths: {0}")] CoreBinaryParsing(String), + #[error("Failed to find any common binaries to determine libc from: {0}")] + NoCommonBinariesFound(String), #[error("Failed to determine libc")] Io(#[from] io::Error), } @@ -207,12 +209,24 @@ fn find_ld_path() -> Result { // See: https://github.com/astral-sh/uv/issues/1810 // See: https://github.com/astral-sh/uv/issues/4242#issuecomment-2306164449 let attempts = ["/bin/sh", "/usr/bin/env", "/bin/dash", "/bin/ls"]; + let mut found_anything = false; for path in attempts { - if let Some(ld_path) = find_ld_path_at(path) { - return Ok(ld_path); + if std::fs::exists(path).ok() == Some(true) { + found_anything = true; + if let Some(ld_path) = find_ld_path_at(path) { + return Ok(ld_path); + } } } - Err(LibcDetectionError::CoreBinaryParsing(attempts.join(", "))) + let attempts_string = attempts.join(", "); + if !found_anything { + // Known failure cases here include running the distroless Docker images directly + // (depending on what subcommand you use) and certain Nix setups. See: + // https://github.com/astral-sh/uv/issues/8635 + Err(LibcDetectionError::NoCommonBinariesFound(attempts_string)) + } else { + Err(LibcDetectionError::CoreBinaryParsing(attempts_string)) + } } /// Attempt to find the path to the `ld` executable by diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index acdeb4e46..edf4087e7 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -87,7 +87,7 @@ pub enum Error { AbsolutePath(PathBuf, #[source] io::Error), #[error(transparent)] NameParseError(#[from] installation::PythonInstallationKeyError), - #[error(transparent)] + #[error("Failed to determine the libc used on the current platform")] LibcDetection(#[from] LibcDetectionError), #[error(transparent)] MacOsDylib(#[from] macos_dylib::Error),