Avoid error on relative paths in uv tool uninstall (#11889)

## Summary

Closes https://github.com/astral-sh/uv/issues/11877.
This commit is contained in:
Charlie Marsh 2025-03-01 20:12:50 -05:00 committed by GitHub
parent 8dd079f2ad
commit cf76334d79
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -75,7 +75,7 @@ impl InstalledTools {
/// 3. A directory in the local data directory, e.g., `./.uv/tools`
pub fn from_settings() -> Result<Self, Error> {
if let Some(tool_dir) = std::env::var_os(EnvVars::UV_TOOL_DIR) {
Ok(Self::from_path(tool_dir))
Ok(Self::from_path(std::path::absolute(tool_dir)?))
} else {
Ok(Self::from_path(
StateStore::from_settings(None)?.bucket(StateBucket::Tools),

View file

@ -38,9 +38,9 @@ pub(crate) async fn uninstall(name: Vec<PackageName>, printer: Printer) -> Resul
fs_err::tokio::remove_dir_all(&installed_tools.root())
.await
.ignore_currently_being_deleted()?;
if let Some(top_level) = installed_tools.root().parent() {
if uv_fs::directories(top_level).all(|path| uv_fs::is_temporary(&path)) {
fs_err::tokio::remove_dir_all(top_level)
if let Some(parent) = installed_tools.root().parent() {
if uv_fs::directories(parent).all(|path| uv_fs::is_temporary(&path)) {
fs_err::tokio::remove_dir_all(parent)
.await
.ignore_currently_being_deleted()?;
}