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 pypa#1164
  • Loading branch information
dechamps committed Dec 25, 2023
1 parent dfe9027 commit e9d9145
Showing 1 changed file with 4 additions and 1 deletion.
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 e9d9145

Please sign in to comment.