Skip to content

Commit

Permalink
Call rmdir with the real path
Browse files Browse the repository at this point in the history
This gets rid of the following warning when using the Microsoft Store
version of Python:

  The system cannot find the path specified.
  Failed to delete C:\Users\etien\AppData\Local\pipx\pipx\trash. You may need to delete it manually.

See also #1164
  • Loading branch information
dechamps committed Dec 28, 2023
1 parent c84e8d2 commit 5a16aac
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## dev

- Fix "Failed to delete" error when using Microsoft Store Python
- Fix "No pyvenv.cfg file" error when using Microsoft Store Python (#1164)
- Add `--quiet` and `--verbose` options for the `pipx` subcommands
- [docs] Add Scoop installation instructions
Expand Down
4 changes: 3 additions & 1 deletion src/pipx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def rmdir(path: Path, safe_rm: bool = True) -> None:
logger.info(f"removing directory {path}")
try:
if WINDOWS:
os.system(f'rmdir /S /Q "{str(path)}"')
# The packaged app (Microsoft Store) version of Python uses path redirections, but `rmdir` won't follow
# these, so use realpath() to manually apply the redirection first.
os.system(f'rmdir /S /Q "{os.path.realpath(path)}"')
else:
shutil.rmtree(path)
except FileNotFoundError:
Expand Down

0 comments on commit 5a16aac

Please sign in to comment.