From 452cafc63988e797f4fc897112a911196ba47e45 Mon Sep 17 00:00:00 2001 From: Ahmed Ilyas Date: Thu, 9 Jan 2025 22:48:06 +0100 Subject: [PATCH] Improve tool list output when tool environment is broken (#10409) ## Summary Closes #9579 ## Test Plan `cargo test` Screenshot 2025-01-08 at 21 13 11 --- crates/uv/src/commands/tool/list.rs | 9 ++++++++- crates/uv/tests/it/tool_list.rs | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/uv/src/commands/tool/list.rs b/crates/uv/src/commands/tool/list.rs index 35e5860af239..721ed9de25be 100644 --- a/crates/uv/src/commands/tool/list.rs +++ b/crates/uv/src/commands/tool/list.rs @@ -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; } }; diff --git a/crates/uv/tests/it/tool_list.rs b/crates/uv/tests/it/tool_list.rs index 71e17f87c78a..d0b0d6b9389f 100644 --- a/crates/uv/tests/it/tool_list.rs +++ b/crates/uv/tests/it/tool_list.rs @@ -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) "### );