Skip to content

Commit d952a97

Browse files
authored
Improve uvx error message when uv is missing (#9745)
from #9742 ``` ❯ cargo run -q --bin uvx Provide a command to run with `uvx <command>`. The following tools are installed: - ansible-core v2.17.5 - black v24.10.0 - rooster-blue v0.0.0 See `uvx --help` for more information. ❯ rm target/debug/uv ❯ cargo run -q --bin uvx error: Could not find the `uv` binary at /Users/zb/workspace/uv/target/debug/uv ```
1 parent 1479f52 commit d952a97

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/uv/src/bin/uvx.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,22 @@ fn run() -> std::io::Result<ExitStatus> {
3030
"Could not determine the location of the `uvx` binary",
3131
));
3232
};
33-
let uv = bin.join("uv");
33+
let uv = bin.join(format!("uv{}", std::env::consts::EXE_SUFFIX));
3434
let args = ["tool", "uvx"]
3535
.iter()
3636
.map(OsString::from)
3737
// Skip the `uvx` name
3838
.chain(std::env::args_os().skip(1))
3939
.collect::<Vec<_>>();
4040

41+
// If we are sure the uv binary does not exist, display a clearer error message
42+
if matches!(uv.try_exists(), Ok(false)) {
43+
return Err(std::io::Error::new(
44+
std::io::ErrorKind::NotFound,
45+
format!("Could not find the `uv` binary at: {}", uv.display()),
46+
));
47+
}
48+
4149
let mut cmd = Command::new(uv);
4250
cmd.args(&args);
4351
match exec_spawn(&mut cmd)? {}

0 commit comments

Comments
 (0)