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

Can't uninstall "cryptography" after installing "requests[security]" #6321

Closed
moloney opened this issue Mar 8, 2019 · 4 comments
Closed
Labels
auto-locked Outdated issues that have been locked by automation C: uninstall The logic for uninstallation of packages resolution: duplicate Duplicate of an existing issue/PR

Comments

@moloney
Copy link

moloney commented Mar 8, 2019

Environment

  • pip version: 19.0.3
  • Python version: 2.7/3.6/3.7
  • OS: Linux (Ubuntu 16.04)

This bug seems to be recent since pip 18.1 doesn't appear to show this behavior.

Description

After installing "requests[security]" which will in turn install "cryptography" as a dependency, it becomes impossible to uninstall the "cryptography" as you end up with a permissions error that only the root user can work around.

Expected behavior

Should be able to uninstall the package as the same user who performed the install.

How to Reproduce

Create a virtual environment and make sure pip is updated to 19.0.3. Install "requests[security]" and then try to uninstall "cryptography". You will get a permissions error on a subdirectory "bindings".

Output

$ python -m venv test-env
$ test-env/bin/pip install -U pip
Looking in links: /usr/global/python/wheels
Collecting pip
Installing collected packages: pip
  Found existing installation: pip 18.1
    Uninstalling pip-18.1:
      Successfully uninstalled pip-18.1
Successfully installed pip-19.0.3
$ test-env/bin/pip install requests[security]
Looking in links: /usr/global/python/wheels
Collecting requests[security]
Collecting urllib3<1.25,>=1.21.1 (from requests[security])
Collecting certifi>=2017.4.17 (from requests[security])
Collecting chardet<3.1.0,>=3.0.2 (from requests[security])
Collecting idna<2.9,>=2.5 (from requests[security])
Collecting pyOpenSSL>=0.14; extra == "security" (from requests[security])
Collecting cryptography>=1.3.4; extra == "security" (from requests[security])
Collecting six>=1.5.2 (from pyOpenSSL>=0.14; extra == "security"->requests[security])
Collecting cffi!=1.11.3,>=1.8 (from cryptography>=1.3.4; extra == "security"->requests[security])
Collecting asn1crypto>=0.21.0 (from cryptography>=1.3.4; extra == "security"->requests[security])
Collecting pycparser (from cffi!=1.11.3,>=1.8->cryptography>=1.3.4; extra == "security"->requests[security])
Installing collected packages: urllib3, certifi, chardet, idna, pycparser, cffi, asn1crypto, six, cryptography, pyOpenSSL, requests
Successfully installed asn1crypto-0.24.0 certifi-2018.11.29 cffi-1.12.2 chardet-3.0.4 cryptography-2.6.1 idna-2.8 pyOpenSSL-19.0.0 pycparser-2.19 requests-2.21.0 six-1.12.0 urllib3-1.24.1
$ test-env/bin/pip uninstall cryptography
Uninstalling cryptography-2.6.1:
  Would remove:
    /remote_home/moloney/test-env/lib/python3.6/site-packages/cryptography-2.6.1.dist-info/*
    /remote_home/moloney/test-env/lib/python3.6/site-packages/cryptography/*
Proceed (y/n)? y
  Successfully uninstalled cryptography-2.6.1
Exception:
Traceback (most recent call last):
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/cli/base_command.py", line 179, in main
    status = self.run(options, args)
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/commands/uninstall.py", line 78, in run
    uninstall_pathset.commit()
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/req/req_uninstall.py", line 412, in commit
    self._moved_paths.commit()
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/req/req_uninstall.py", line 263, in commit
    save_dir.cleanup()
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/utils/temp_dir.py", line 83, in cleanup
    rmtree(self.path)
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_vendor/retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_vendor/retrying.py", line 212, in call
    raise attempt.get()
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_vendor/retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_vendor/six.py", line 693, in reraise
    raise value
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_vendor/retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "/remote_home/moloney/test-env/lib/python3.6/site-packages/pip/_internal/utils/misc.py", line 121, in rmtree
    onerror=rmtree_errorhandler)
  File "/usr/global/python/versions/3.6.8/lib/python3.6/shutil.py", line 486, in rmtree
    _rmtree_safe_fd(fd, path, onerror)
  File "/usr/global/python/versions/3.6.8/lib/python3.6/shutil.py", line 424, in _rmtree_safe_fd
    _rmtree_safe_fd(dirfd, fullname, onerror)
  File "/usr/global/python/versions/3.6.8/lib/python3.6/shutil.py", line 420, in _rmtree_safe_fd
    onerror(os.open, fullname, sys.exc_info())
  File "/usr/global/python/versions/3.6.8/lib/python3.6/shutil.py", line 418, in _rmtree_safe_fd
    dirfd = os.open(name, os.O_RDONLY, dir_fd=topfd)
PermissionError: [Errno 13] Permission denied: 'bindings'

@cjerdonek cjerdonek added C: uninstall The logic for uninstallation of packages S: needs triage Issues/PRs that need to be triaged labels Mar 10, 2019
@cjerdonek
Copy link
Member

@zooba It looks like the traceback in this report goes through lines that you introduced in your PR #6215. Can you take a look?

@cjerdonek
Copy link
Member

Issue #6327 was also just filed, which looks like the same issue but with more information.

@cjerdonek
Copy link
Member

Even though this issue was filed earlier, I'm going to close this issue as a duplicate in favor of #6327 as it has more discussion.

@cjerdonek cjerdonek added resolution: duplicate Duplicate of an existing issue/PR and removed S: needs triage Issues/PRs that need to be triaged labels Mar 22, 2019
@lock
Copy link

lock bot commented May 28, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label May 28, 2019
@lock lock bot locked as resolved and limited conversation to collaborators May 28, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: uninstall The logic for uninstallation of packages resolution: duplicate Duplicate of an existing issue/PR
Projects
None yet
Development

No branches or pull requests

2 participants