Improve tool list output when tool environment is broken (#10409)

## Summary

Closes #9579 

## Test Plan

`cargo test`


<img width="1110" alt="Screenshot 2025-01-08 at 21 13 11"
src="https://github.com/user-attachments/assets/8937c14e-c594-470f-a8f2-77ac7167794f"
/>
This commit is contained in:
Ahmed Ilyas
2025-01-09 22:48:06 +01:00
committed by GitHub
parent d77598a08c
commit 452cafc639
2 changed files with 9 additions and 2 deletions
+8 -1
View File
@@ -51,7 +51,14 @@ pub(crate) async fn list(
let version = match installed_tools.version(&name, cache) {
Ok(version) => version,
Err(e) => {
writeln!(printer.stderr(), "{e}")?;
if let uv_tool::Error::EnvironmentError(e) = e {
warn_user!(
"{e} (run `{}` to reinstall)",
format!("uv tool install {name} --reinstall").green()
);
} else {
writeln!(printer.stderr(), "{e}")?;
}
continue;
}
};
+1 -1
View File
@@ -156,7 +156,7 @@ fn tool_list_bad_environment() -> Result<()> {
- ruff
----- stderr -----
Invalid environment at `tools/black`: missing Python executable at `tools/black/[BIN]/python`
warning: Invalid environment at `tools/black`: missing Python executable at `tools/black/[BIN]/python` (run `uv tool install black --reinstall` to reinstall)
"###
);