Skip to content

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

@pdegroote

Description

@pdegroote

What's the problem this feature will solve?

When installing packages in development mode, and sloppy removal of those folders (instead of uninstall), the error

Egg-link {} does not match installed location of {} (at {}) (pip/req_uninstall.py, line 535)

is sometimes raised when installing a new package of the same name from a different folder. The issue can be solved by manually removing the egg-link, but it may sometimes be difficult to find it, certainly for people not very experienced with pip (it could be installed in site-packages of the python installation, or maybe UserData on Windows, ...). A better error message should make it easier to find it, and remove it.

Describe the solution you'd like

I suggest to change this code (starting line 529 in pip/req_uninstall)

elif develop_egg_link:
            # develop egg
            with open(develop_egg_link) as fh:
                link_pointer = os.path.normcase(fh.readline().strip())
            assert (
                link_pointer == dist.location
            ), "Egg-link {} does not match installed location of {} (at {})".format(
                link_pointer, dist.project_name, dist.location
            )

with this (adding not only the contents of "develop_egg_link" to the error message, but also the path of the file itself):

elif develop_egg_link:
            # develop egg
            with open(develop_egg_link) as fh:
                link_pointer = os.path.normcase(fh.readline().strip())
            assert (
                link_pointer == dist.location
            ), "Egg-link {} at {} does not match installed location of {} (at {})".format(
                link_pointer, develop_egg_link, dist.project_name, dist.location
            )

Alternative Solutions

I don't know about any alternative solutions; maybe forcing uninstall could help eventually, but if this happens in the course of a CI pipeline, then an improved error message is saves a lot of time.

Additional context

I've never contributed to pip, but wouldn't mind making this contribution myself, it doesn't seem to pose any big risks.

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions