Skip to content

Commit

Permalink
Remove dangling environments in tool uninstall
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Jul 2, 2024
1 parent 32dc9be commit 92dd804
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion crates/uv/src/commands/tool/uninstall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,22 @@ pub(crate) async fn uninstall(

let installed_tools = InstalledTools::from_settings()?;
let Some(receipt) = installed_tools.get_tool_receipt(&name)? else {
bail!("Tool `{}` is not installed", name);
// If the tool is not installed, attempt to remove the environment anyway.
match installed_tools.remove_environment(&name) {
Ok(()) => {
writeln!(
printer.stderr(),
"Removed dangling environment for tool: `{name}` (missing receipt)"
)?;
return Ok(ExitStatus::Success);
}
Err(uv_tool::Error::IO(err)) if err.kind() == std::io::ErrorKind::NotFound => {
bail!("Tool `{name}` is not installed");
}
Err(err) => {
return Err(err.into());
}
}
};

// Remove the tool itself.
Expand Down

0 comments on commit 92dd804

Please sign in to comment.