From dc80b18487128405d0bddc3f1d7f7b3dc9f54ed0 Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Thu, 9 Oct 2025 13:12:04 +0200 Subject: [PATCH 1/7] Replace `remove_dir_all` with `remove_virtualenv` --- crates/uv-tool/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index d1330efe3..60aa5a71c 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -251,14 +251,13 @@ impl InstalledTools { let environment_path = self.tool_dir(name); // Remove any existing environment. - match fs_err::remove_dir_all(&environment_path) { + match remove_virtualenv(&environment_path) { Ok(()) => { debug!( "Removed existing environment for tool `{name}`: {}", environment_path.user_display() ); } - Err(err) if err.kind() == io::ErrorKind::NotFound => (), Err(err) => return Err(err.into()), } From 1726b4b31fe9346aaa45f78f9e33b76ab7da3f56 Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Thu, 9 Oct 2025 19:39:05 +0200 Subject: [PATCH 3/7] Reverting for a sanity check --- crates/uv-tool/src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index 60aa5a71c..94320abb3 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -251,13 +251,14 @@ impl InstalledTools { let environment_path = self.tool_dir(name); // Remove any existing environment. - match remove_virtualenv(&environment_path) { + match fs_err::remove_dir(&environment_path) { Ok(()) => { debug!( "Removed existing environment for tool `{name}`: {}", environment_path.user_display() ); } + Err(err) if err.kind() == io::ErrorKind::NotFound => (), Err(err) => return Err(err.into()), } From eaf323f69aa099ae5f71004023b46090c7f4d37c Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Thu, 9 Oct 2025 19:42:20 +0200 Subject: [PATCH 4/7] Actual revert --- crates/uv-tool/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index 94320abb3..d1330efe3 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -251,7 +251,7 @@ impl InstalledTools { let environment_path = self.tool_dir(name); // Remove any existing environment. - match fs_err::remove_dir(&environment_path) { + match fs_err::remove_dir_all(&environment_path) { Ok(()) => { debug!( "Removed existing environment for tool `{name}`: {}", From aa045f647abcd6ae1eb8f5059a43f32e6d4d909a Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Thu, 9 Oct 2025 19:56:12 +0200 Subject: [PATCH 5/7] Reapplying, sanity check succeeded --- crates/uv-tool/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index d1330efe3..60aa5a71c 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -251,14 +251,13 @@ impl InstalledTools { let environment_path = self.tool_dir(name); // Remove any existing environment. - match fs_err::remove_dir_all(&environment_path) { + match remove_virtualenv(&environment_path) { Ok(()) => { debug!( "Removed existing environment for tool `{name}`: {}", environment_path.user_display() ); } - Err(err) if err.kind() == io::ErrorKind::NotFound => (), Err(err) => return Err(err.into()), } From 68a947860e4d3ced213367cd9ca881b07751dd13 Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Sat, 11 Oct 2025 14:56:54 +0200 Subject: [PATCH 6/7] Add back IO error handling --- crates/uv-tool/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index 60aa5a71c..e85e81ddd 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -258,6 +258,7 @@ impl InstalledTools { environment_path.user_display() ); } + Err(uv_virtualenv::Error::Io(_)) => (), Err(err) => return Err(err.into()), } From ac0ea6651b1cb1d0d31f67a748d50199d6b55831 Mon Sep 17 00:00:00 2001 From: Mitchell Berendhuysen Date: Sat, 11 Oct 2025 15:07:05 +0200 Subject: [PATCH 7/7] Actually handling the error properly --- crates/uv-tool/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/uv-tool/src/lib.rs b/crates/uv-tool/src/lib.rs index e85e81ddd..4c106362f 100644 --- a/crates/uv-tool/src/lib.rs +++ b/crates/uv-tool/src/lib.rs @@ -258,7 +258,11 @@ impl InstalledTools { environment_path.user_display() ); } - Err(uv_virtualenv::Error::Io(_)) => (), + Err(uv_virtualenv::Error::Io(err)) => { + if err.kind() != io::ErrorKind::NotFound { + return Err(err.into()); + } + } Err(err) => return Err(err.into()), }