Skip to content
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

Improve error message when egg-link does not match installed location #10594

Merged
merged 3 commits into from
Apr 10, 2023

Conversation

pdegroote
Copy link

@pdegroote pdegroote commented Oct 17, 2021

Improve error message when a pip package cannot be reinstalled after an egg link to a development package persists, but the original folder has been deleted.

This may help in finding the location of the egg link that needs to be manually removed by a user to solve the problem. It appears it only occurs in very specific situations, and maybe even only before PEP517. I encountered the issue in my company on our build server, but it wasn't trivial to reproduce it locally (I took an older version of Python and legacy pip option just to be sure, and I also couldn't have a toml file in the main directory). The following workflow reproduces the issue (but I'm not 100% sure what are the required steps, maybe some of the steps below allow variations). I tested it only on Windows 10.

  1. Install Python 3.8.10 in an administrator folder (e.g. C:\Program Files\Python)
  2. Clone the pypa sample project to a directory, e.g. "sample1", and remove the toml and tox.ini file
  3. Install the sample project in a user directory in development mode:
    "C:\Program Files\Python\python.exe -m pip install --user --no-use-pep517 -e .
  4. Delete sample1 (or rename, to invalidate the directory)
  5. Clone the pypa sample project to a new directory (e.g. "sample2" and remove the toml and tox.ini file
  6. Try to install sample2 as user "C:\Program Files\Python\python.exe -m pip install --user --no-use-pep517 -e .

I get the following error message:

image

The problem is that it is not clear where the conflicting egg link is located, which is particularly difficult when working from build accounts where user directories may not be directly clear.

For a description of the issue, see #10476 ( #10476. )

@pradyunsg
Copy link
Member

FWIW, I have a local change that's a part of #10421 that'll conflict with this one -- it is one of the follow ups I have for when #10538 is merged, since going down that PR's framework makes it much nicer to be able to present better error messages.

@uranusjr
Copy link
Member

Now this needs a news file and some fixes to satisfy checkers.

@uranusjr
Copy link
Member

I think this is worth listing as a feature, not trivial.

news/10476.feature.rst Outdated Show resolved Hide resolved
@pradyunsg

This comment has been minimized.

@pradyunsg
Copy link
Member

Hmm... @pdegroote would it be OK if I pick this PR up and make CI be happy with it?

@pdegroote
Copy link
Author

Hmm... @pdegroote would it be OK if I pick this PR up and make CI be happy with it?

Yes please! This is my first attempt at contributing to pip, and still need to learn the flow.

matpdegroote2 and others added 2 commits October 22, 2021 10:07
Include the locations of the mismatched locations in the message, to
provide more context.
Co-authored-by: Pradyun Gedam <[email protected]>
Co-authored-by: Tzu-ping Chung <[email protected]>
@pradyunsg
Copy link
Member

Yes please! This is my first attempt at contributing to pip, and still need to learn the flow.

Sure, happy to help!

Here's what I've done to update this PR:

  • I ran git rebase --interactive main (here, main refers to the main branch in my local clone, not your PR -- see https://hackernoon.com/beginners-guide-to-interactive-rebasing-346a3f9c3a6d which seems like a reasonable guide to this).
    • Squashed all the code changes into a single commit, and newfile changes into a second commit.
  • Pushed and waited for CI to run -- it failed with a pre-commit issue and a docs issue.
    • the "docs" build is also failing in the main branch of pip in the same way, which means the failure is unrelated to this change.
    • the "pre-commit" build says that some content isn't properly formatted.
      • I ran nox -s lint (you can also run tox -e lint) locally, to run the automated code formatters and code style checks and made sure there's no other errors.
  • Made a commit fixing the reported failures.
  • Did another interactive rebase, squashing the above fixes into the first commit (the one that did the code changes).
    • Waited, and saw that pre-commit is happy + docs is as it is in pip's main branch. :)

One suggestion: Make a new branch (like git branch improve-egg-link-error-message followed by git checkout improve-egg-link-error-message).

  • It is generally a "best practice" to not make a pull request from your fork's main branch.
  • Ideally, your fork's main branch reflects the same contents as the main branch on this repository.

@github-actions github-actions bot added the needs rebase or merge PR has conflicts with current master label Nov 22, 2021
Copy link
Member

@DiddiLeija DiddiLeija left a comment

Choose a reason for hiding this comment

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

Hi @pdegroote. This PR looks good!

Would you like to rebase this PR, or do you prefer to give us the chance to do it?

@pypa-bot pypa-bot removed the needs rebase or merge PR has conflicts with current master label Mar 27, 2023
@uranusjr uranusjr merged commit d0c50a0 into pypa:main Apr 10, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants