Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion crates/uv/src/commands/tool/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,12 @@ async fn do_uninstall(
// If the tool is not installed properly, attempt to remove the environment anyway.
match installed_tools.remove_environment(&name) {
Ok(()) => {
dangling = true;
writeln!(
printer.stderr(),
"Removed dangling environment for `{name}`"
)?;
return Ok(());
continue;
}
Err(uv_tool::Error::VirtualEnvError(uv_virtualenv::Error::Io(err)))
if err.kind() == std::io::ErrorKind::NotFound =>
Expand Down
50 changes: 50 additions & 0 deletions crates/uv/tests/it/tool_uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,56 @@ fn tool_uninstall_missing_receipt() {
");
}

#[test]
fn tool_uninstall_multiple_names_with_missing_receipt() {
let context = uv_test::test_context!("3.12").with_filtered_exe_suffix();
let tool_dir = context.temp_dir.child("tools");
let bin_dir = context.temp_dir.child("bin");

// Install `black`
context
.tool_install()
.arg("black==24.2.0")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str())
.assert()
.success();

context
.tool_install()
.arg("ruff==0.3.4")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str())
.assert()
.success();

fs_err::remove_file(tool_dir.join("black").join("uv-receipt.toml")).unwrap();

uv_snapshot!(context.filters(), context.tool_uninstall().arg("black").arg("ruff")
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
Removed dangling environment for `black`
Uninstalled 1 executable: ruff
");

// After uninstalling both tools, neither should be listed.
uv_snapshot!(context.filters(), context.tool_list()
.env(EnvVars::UV_TOOL_DIR, tool_dir.as_os_str())
.env(EnvVars::XDG_BIN_HOME, bin_dir.as_os_str()), @"
success: true
exit_code: 0
----- stdout -----

----- stderr -----
No tools installed
");
}

#[test]
fn tool_uninstall_all_missing_receipt() {
let context = uv_test::test_context!("3.12").with_filtered_exe_suffix();
Expand Down
Loading