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 24, 2023
1 parent 881785f commit 5a55af1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions pipx_shared.pth
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
C:\Users\etien\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\Local\pipx\pipx\shared\Lib\site-packages
5 changes: 4 additions & 1 deletion src/pipx/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ 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 5a55af1

Please sign in to comment.