From 63afdeb260b556fac4eb6a9b234a40d1af2c3a36 Mon Sep 17 00:00:00 2001 From: Etienne Dechamps Date: Sun, 24 Dec 2023 13:07:23 +0000 Subject: [PATCH] Call rmdir with the real path 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 --- src/pipx/util.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pipx/util.py b/src/pipx/util.py index 24ef45b548..750a064596 100644 --- a/src/pipx/util.py +++ b/src/pipx/util.py @@ -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: