Clear junction properly when uninstalling Python versions on Windows#18815
Open
Clear junction properly when uninstalling Python versions on Windows#18815
Conversation
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
Signed-off-by: William Woodruff <william@astral.sh>
00c11df to
d1980c2
Compare
Member
Author
|
Specifically, this is the problematic check in https://docs.rs/junction/1.4.2/src/junction/internals.rs.html#116-118
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Reproduces and fixes #18793.
Previously, when uninstalling Python versions on Windows, we'd remove junctions (i.e. soft links) for the minor version after deleting the installation itself. This worked correctly on Linux and macOS but not on Windows, since on Windows we'd call
junction::get_target(viaPythonMinorVersionLink::exists), which would fail because the junction would be dangling following the deletion. Specifically,read_targetreturnsNone, short circuiting thetarget_directorycheck.The fix here is to reorder the uninstallation flow so that we precompute and remove the links before the underlying installations are deleted. I've added two tests that both reproduced the behavior and now demonstrate the fix working.
Note: 81c27ba shows a smaller alternative fix -- instead of reordering the installation flow, we can change the "entry exists" logic on Windows to not require that the target still exists. I believe this would also be functionally correct, but I think reordering the uninstallation flow makes more sense (in terms of eliminating the surprising state rather than trying to work around it).
Test Plan
Look at me, I am the test plan now.