Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let self-managed pipx uninstall itself on windows again #1231

Merged
merged 3 commits into from
Feb 12, 2024
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
1 change: 1 addition & 0 deletions changelog.d/1203.bugfix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Let self-managed pipx uninstall itself on windows again.
9 changes: 5 additions & 4 deletions src/pipx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,11 @@ def rmdir(path: Path, safe_rm: bool = True) -> None:
return

logger.info(f"removing directory {path}")
try:
shutil.rmtree(path)
except FileNotFoundError:
pass
# Windows doesn't let us delete or overwrite files that are being run
# But it does let us rename/move it. To get around this issue, we can move
# the file to a temporary folder (to be deleted at a later time)
# So, if safe_rm is True, we ignore any errors and move the file to the trash with below code
shutil.rmtree(path, ignore_errors=safe_rm)

# move it to be deleted later if it still exists
if path.is_dir():
Expand Down