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

pip fails on uninstall of console script if a link is in the path #3141

Closed
AvdN opened this Issue Sep 26, 2015 · 3 comments

Comments

Projects
None yet
3 participants
@AvdN

AvdN commented Sep 26, 2015

I have a virtualenv that is installed under my home directory. My home directory is a link to another directory. When uninstalling a package that was installed with pip install ., the console script in this package is removed twice, once with the links in its path resolved, once with the links. Of course the second remove fails.

I traced this down to InstallRequirement.uninstall() (in req/req_install.py). This builds up the paths to be removed and bases those on from the list in installed-files.txt on dist.egg_info, which is a real path (i.e. links removed with os.path.realpath()) ( I am not sure where this actually is being set). The console script is in this list.

Later on in uninstall(), the entrypoints.txt is parsed, but the paths from there are constructed based on bindir, which is in my case not a real path. The console script is added once more to the list, with a different path (that resolves to the same path if links are removed).

This causes UninstallPathSet.remove() in req.req_uninstall.py to not recognize the two paths to the consolescript to be the same when trying to call its .compact() method, and thus it fails removing because the file was just removed.

Importing normalize_path from pip.utils and using that before adding the console script path resolves the issue (line 704):

                else:
                    bin_dir = bin_py
                paths_to_remove.add(normalize_path(os.path.join(bin_dir, name)))
                if WINDOWS:
                    paths_to_remove.add(
                        os.path.join(bin_dir, name) + '.exe'
@AvdN

This comment has been minimized.

Show comment
Hide comment
@AvdN

AvdN Sep 26, 2015

PR for this: #3142

AvdN commented Sep 26, 2015

PR for this: #3142

@xavfernandez

This comment has been minimized.

Show comment
Hide comment
@xavfernandez

xavfernandez Sep 28, 2015

Contributor

This is a duplicate of #3011.
But I think I like your solution better.

Contributor

xavfernandez commented Sep 28, 2015

This is a duplicate of #3011.
But I think I like your solution better.

@qwcode

This comment has been minimized.

Show comment
Hide comment
@qwcode

qwcode Oct 3, 2015

Contributor

fixed in PR #3154

Contributor

qwcode commented Oct 3, 2015

fixed in PR #3154

@qwcode qwcode closed this Oct 3, 2015

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