diff --git a/crates/uv/src/bin/uvx.rs b/crates/uv/src/bin/uvx.rs index 86c1044476ec..cd00ed9fdcc5 100644 --- a/crates/uv/src/bin/uvx.rs +++ b/crates/uv/src/bin/uvx.rs @@ -30,7 +30,7 @@ fn run() -> std::io::Result { "Could not determine the location of the `uvx` binary", )); }; - let uv = bin.join("uv"); + let uv = bin.join(format!("uv{}", std::env::consts::EXE_SUFFIX)); let args = ["tool", "uvx"] .iter() .map(OsString::from) @@ -38,6 +38,14 @@ fn run() -> std::io::Result { .chain(std::env::args_os().skip(1)) .collect::>(); + // If we are sure the uv binary does not exist, display a clearer error message + if matches!(uv.try_exists(), Ok(false)) { + return Err(std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("Could not find the `uv` binary at: {}", uv.display()), + )); + } + let mut cmd = Command::new(uv); cmd.args(&args); match exec_spawn(&mut cmd)? {}