Skip to content

pip 19.x --upgrade breaks on nfs #6327

@ntextreme3

Description

@ntextreme3

Environment

  • pip version: 19.x
  • Python version: 2.7, 3.6
  • OS: Linux

Description
pip19 uses AdjacentTempDirectory, where previous pip versions used tempfile. Because of nfs "silly rename", if working on an nfs mount and pip is called via a subprocess from a python script that happens to use one of the packages being upgraded, pip fails when trying to cleanup (since the C extensions are still mapped to interpreter -- can be seen in /proc/$PID/maps)

Expected behavior

Expect this either to not fail (as in previous versions of pip) or just raise more appropriate exception. Right now, this causes pip to enter this error handler (that seems to be designed for windows). chmod'ing the path to 200 works for Windows, but is not enough to delete on Linux. The chmod done here ultimately causes pip to raise Permission Error. Maybe that should be chmod to stat.S_IRWXU?

How to Reproduce

in some nfs location, install simplejson (or anything that uses a C extension)

python3.6 -m virtualenv env
source env/bin/activate
pip install simplejson==3.16.0

then import it, and call pip in a subprocess

import subprocess
import sys

import simplejson  # <-- causes this to break


INSTALL_COMMAND = [
    sys.executable,
    "-m",
    "pip",
    "install",
    "--disable-pip-version-check",
    "--upgrade",
    "--force-reinstall",
    "simplejson==3.16.0",
]
print("return code:", subprocess.Popen(INSTALL_COMMAND).wait())

You can also run the script interactively and see the mapped files. I saved above code as 'mini.py'

$ python -i mini.py &
# wait for the pip process to finish
$ cat /proc/$!/maps | grep nfs
# will show the .nfs* files

Output

Looking in indexes: https://...
Collecting simplejson==3.16.0
Installing collected packages: simplejson
  Found existing installation: simplejson 3.16.0
    Uninstalling simplejson-3.16.0:
      Successfully uninstalled simplejson-3.16.0
Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'env/lib/python3.6/site-packages/~implejson'
Consider using the `--user` option or check the permissions.

return code: 1

Taking a look at that location:

$ ls env/lib/python3.6/site-packages/~implejson
ls: cannot open directory 'env/lib/python3.6/site-packages/~implejson': Permission denied
$ chmod 700 env/lib/python3.6/site-packages/~implejson
$ ls -a env/lib/python3.6/site-packages/~implejson
.  ..  .nfsxxxxxxxxxxxxxxxxxxxxxxxx  # <-- some nfs silly-renamed file
Paste the output of the steps above, including the commands themselves and
pip's output/traceback etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions