Skip to content

Clarify warning for incompletely removed distributions - #14047

Open
2ykwang wants to merge 7 commits into
pypa:mainfrom
2ykwang:clarify-leftover-warning
Open

Clarify warning for incompletely removed distributions#14047
2ykwang wants to merge 7 commits into
pypa:mainfrom
2ykwang:clarify-leftover-warning

Conversation

@2ykwang

@2ykwang 2ykwang commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Fixes #11849.

add a distinct warning for ~ -prefixed leftovers, marking them as incompletely removed and safe to delete.

the check uses the metadata directory name instead of the distribution name, since pkg_resources (default on 3.10) turns the leading ~ into -. Open to a different approach.

output:

image

@sepehr-rs

Copy link
Copy Markdown
Member

Hi @2ykwang, thanks for the contribution!
Just a heads-up that pip is a volunteer project, so it may take some time before a maintainer gets to review this.
Appreciate the PR!

@2ykwang

2ykwang commented Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @sepehr-rs appreciate it. no rush!

@2ykwang
2ykwang force-pushed the clarify-leftover-warning branch from 522c0f3 to 9d4f429 Compare June 12, 2026 16:19
@2ykwang
2ykwang force-pushed the clarify-leftover-warning branch from 9d4f429 to 153a445 Compare June 12, 2026 16:30

@sepehr-rs sepehr-rs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your contribution!
I tested this locally and the new warning message is more user-friendly. The tests look good too.
I do have one comment on the leftover_name logic that's worth addressing for future releases. Besides that, LGTM from me!
Let me know if you have any questions.

Comment thread src/pip/_internal/metadata/base.py Outdated
@ichard26
ichard26 self-requested a review June 20, 2026 20:13
@ichard26 ichard26 added this to the 26.3 milestone Jul 27, 2026
@ichard26

ichard26 commented Aug 3, 2026

Copy link
Copy Markdown
Member

Sorry for taking a while to review this. My overall concern is that I'm not too sure what happens when an incompletely removed distribution is left. I'm fairly certain it's safe to remove in 95% of situations, but I don't know where it could go wrong.

I'll take a closer look when I can when I have more time to dig into the uninstall code.

@pfmoore

pfmoore commented Aug 4, 2026

Copy link
Copy Markdown
Member

Maybe we should just qualify the message a little?

'~'-prefixed leftover directories are the result of a previous incomplete installation, and can be deleted.

By explaining the cause, and deliberately omitting the word "safe", we still indicate what the user should do, but with the implication that "if you want to be cautious, you should work out why the previous installation failed".

@2ykwang

2ykwang commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

@pfmoore 's suggestion sounds like a good compromise to me, since it avoids stating categorically that the directories are safe to delete.
I also think the message could be more helpful if it explained what happens when those directories are deleted.

@ichard26

ichard26 commented Aug 6, 2026

Copy link
Copy Markdown
Member

+1 to @pfmoore's suggestion. It'd still be nice to understand when ~ prefixed directories are left though (with the rewording, it's not essential to accepting this PR, but I'm more comfortable when I have the larger picture).

@2ykwang

2ykwang commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

before updating the wording. I'll also look into this a bit more

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better warning message for undeleted temp directories in site-packages

4 participants