-
Notifications
You must be signed in to change notification settings - Fork 476
Closed
Labels
Description
Attempting to reinstall xonsh
on Windows while xonsh
is running, it fails with a PermissionError:
~ @ pipx reinstall xonsh
C:\Users\jaraco\.local\pipx\venvs\xonsh\Scripts\python.exe - Access is denied.
Failed to delete C:\Users\jaraco\.local\pipx\venvs\xonsh. Will move it to a temp folder to delete later.
uninstalled xonsh! ✨ 🌟 ✨
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Users\jaraco\.local\bin\pipx.exe\__main__.py", line 7, in <module>
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\main.py", line 863, in cli
return run_pipx_command(parsed_pipx_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\main.py", line 271, in run_pipx_command
return commands.reinstall(
^^^^^^^^^^^^^^^^^^^
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\commands\reinstall.py", line 62, in reinstall
install(
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\commands\install.py", line 69, in install
run_post_install_actions(
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\commands\common.py", line 386, in run_post_install_actions
expose_apps_globally(
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\commands\common.py", line 58, in expose_apps_globally
_symlink_package_apps(local_bin_dir, app_paths, force=force, suffix=suffix)
File "C:\Users\jaraco\.local\pipx\venvs\pipx\Lib\site-packages\pipx\commands\common.py", line 113, in _symlink_package_apps
symlink_path.unlink()
File "C:\Program Files\Python 3.11\Lib\pathlib.py", line 1147, in unlink
os.unlink(self)
PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'C:\\Users\\jaraco\\.local\\bin\\xonsh.exe'
Afterword, the shell is unusable and the state (injected modules) is lost.
PS C:\Users\jaraco> xonsh
Fatal error in launcher: Unable to create process using '"C:\Users\jaraco\.local\pipx\venvs\xonsh\Scripts\python.exe" "c:\users\jaraco\.local\bin\xonsh.exe" ': The system cannot find the file specified.
PS C:\Users\jaraco> pipx reinstall xonsh
Nothing to reinstall for xonsh 😴
Expected behavior
Ideally, the workaround used for python.exe would also be used by xonsh.exe (move the file to a temporary directory when unable to delete). If that can't be done, it would at least be nice if it could fail early and not leave the reinstall half-completed.