-
Notifications
You must be signed in to change notification settings - Fork 444
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make uninstall on Windows not erroneously uninstall apps from dependencies #672
Conversation
Why does “done!” appear in the output before it’s actually done? |
Ah yes I noticed that too. It's because I am not a "Windows person" and when I use Windows I use MSYS2 and mintty as a shell. It buffers all stdout and stderr and then plays each back in a block, so if they are interspersed they end up out of order. When using Powershell on Windows it all appears in the proper order. |
One thing I notice is that the Github Windows CI machines actually DO ALLOW symlinks. So just now I ran our tests on my local Windows VM and found that one of the tests fails when it succeeds on the Windows CI. This is because by design in the code, if we are on a system without symlinks, no metadata + no python interpreter causes the code to not remove any apps in the local binary directory. However on Github CI this is never tested, because the Github Windows machines all allow symlinks. So I've added a clause to the tests to skip the relevant assertions that binaries were removed in that case on Windows, so the tests work on all Windows machines. Not sure if there's a way to make the Github CI Windows machines not allow symlinks to mimic the typical Windows experience? |
I asked about Windows symlinks on github CI machines |
I suppose I could add an uninstall test for injected apps though. |
Investigating a little further, this seems to be because if you are running as Administrator on Windows, you are allowed to make symbolic links, and if you are running as a regular user, you are not allowed to make symlinks. Apparently on Github machines the tests run as Administrator. We might have to mock the function |
I added a monkeypatch to the This is to get around the fact that Github CI Windows runs as Administrator and thus runs atypically with the ability to make symlinks. |
I'm going to merge this soon unless anyone has any questions or issues they want to bring up. Afterwards I plan on doing the next pipx release. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
https://blogs.windows.com/windowsdeveloper/2016/12/02/symlinks-windows-10/ Does pipx make symlinks on windows if it’s able to? You noted the admin case works, and it looks like it will work more often than not with newer builds of windows. Sorry I am not at my laptop and not able to inspect the code. |
I have the newest version of Windows 10 to play with, and it does NOT allow making symlinks in its stock configuration without being Administrator. The link is very informative though! Apparently you need to put Windows into "Developer Mode" to make shell-based symbolic links work. There is also a Windows API feature that is worth further investigation, which seems to allow any program to utilize symbolic links in any mode (if I'm reading it correctly?) Using the flag |
My thought is that somehow we need to be testing the non-symlink pipx code in CI (We're not currently testing it.) It seems reasonable to test it on Windows since the "normal" behavior of Windows is still to disallow symlinks. But I'm willing to discuss going back to our old testing. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, this is definitely an improvement. Thanks for doing this.
I will say that I'm glad we test if symlinks are possible, rather than simply testing if we're in Windows. In actual use of pipx some Windows users will get the benefit of symlinks. |
Here's another note on this. It seems that even with the win api call to CreateSymbolicLink* with the
|
docs/changelog.md
Summary of changes
Closes #670 .
This fixes a bug on Windows where uninstalling a venv would uninstall app binaries in the local bin directory from its dependencies also (even though the original
pipx install
did not use--include-dependencies
.)This change updates and refactors the code in
uninstall.py
to use the functionget_exposed_app_paths_for_package
fromcommon.py
to determine the associated binaries in the local binary directory for a given venv. It thus benefits from the bug fixes that were applied in #650 tocommon.py
.And as a bonus we get rid of duplicate code in
uninstall.py
that did the same function as code incommon.py
.I also added tests to check that
pipx uninstall
doesn't delete the apps of a dependency if the original app wasn't installed with--include-dependencies
.Also in the test code:
remove_venv_interpreter
mock_legacy_venv
to allowmetadata_version
argument to use the current metadata versioncapsys
intest_uninstall.py
from tests where it was not being used.Test plan
Tested by running on WINDOWS (from example in #670)
This PR result:
pipx 0.16.1 result: (
poetry.exe
is erroneously removed from~/.local/bin
)