mirror of https://github.com/astral-sh/uv
Display selected interpreter sources during not selected error (#4026)
This should help us narrow down the weird error in https://github.com/astral-sh/uv/issues/4023
This commit is contained in:
parent
054fffe05e
commit
2be93c0b2c
|
|
@ -165,8 +165,8 @@ pub enum Error {
|
|||
#[error(transparent)]
|
||||
PyLauncher(#[from] crate::py_launcher::Error),
|
||||
|
||||
#[error("Interpreter discovery for `{0}` requires `{1}` but it is not selected")]
|
||||
SourceNotSelected(InterpreterRequest, InterpreterSource),
|
||||
#[error("Interpreter discovery for `{0}` requires `{1}` but it is not selected; the following are selected: {2}")]
|
||||
SourceNotSelected(InterpreterRequest, InterpreterSource, SourceSelector),
|
||||
}
|
||||
|
||||
/// Lazily iterate over all discoverable Python executables.
|
||||
|
|
@ -466,6 +466,7 @@ pub fn find_interpreter(
|
|||
return Err(Error::SourceNotSelected(
|
||||
request.clone(),
|
||||
InterpreterSource::ProvidedPath,
|
||||
sources.clone(),
|
||||
));
|
||||
}
|
||||
if !path.try_exists()? {
|
||||
|
|
@ -484,6 +485,7 @@ pub fn find_interpreter(
|
|||
return Err(Error::SourceNotSelected(
|
||||
request.clone(),
|
||||
InterpreterSource::ProvidedPath,
|
||||
sources.clone(),
|
||||
));
|
||||
}
|
||||
if !path.try_exists()? {
|
||||
|
|
@ -508,6 +510,7 @@ pub fn find_interpreter(
|
|||
return Err(Error::SourceNotSelected(
|
||||
request.clone(),
|
||||
InterpreterSource::SearchPath,
|
||||
sources.clone(),
|
||||
));
|
||||
}
|
||||
let Some(executable) = which(name).ok() else {
|
||||
|
|
|
|||
|
|
@ -1421,7 +1421,11 @@ mod tests {
|
|||
matches!(
|
||||
result,
|
||||
Err(Error::Discovery(
|
||||
crate::discovery::Error::SourceNotSelected(_, InterpreterSource::ProvidedPath)
|
||||
crate::discovery::Error::SourceNotSelected(
|
||||
_,
|
||||
InterpreterSource::ProvidedPath,
|
||||
_
|
||||
)
|
||||
))
|
||||
),
|
||||
// TODO(zanieb): We should allow this, just enforce it's a virtualenv
|
||||
|
|
|
|||
Loading…
Reference in New Issue