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

pip-6.0.8 uninstall tries to remove non-existent file (and then crashes loudly) #2953

Closed
PAStheLoD opened this issue Jul 3, 2015 · 8 comments
Labels
auto-locked Outdated issues that have been locked by automation

Comments

@PAStheLoD
Copy link

Hello!

I'm encountering a really strange error. It goes away after upgrading pip.

  ...
  Downloading pip-7.1.0-py2.py3-none-any.whl (1.1MB)
  Downloading from URL https://pypi.python.org/packages/py2.py3/p/pip/pip-7.1.0-py2.py3-none-any.whl#md5=b108384a762825ec20345bb9b5b7209f
    100% |################################| 1.1MB 463kB/s 
Installing collected packages: pip
  Found existing installation: pip 6.0.8
    Uninstalling pip-6.0.8:
      Removing file or directory /usr/local/bin/pip
      Removing file or directory /usr/local/bin/pip3
      Removing file or directory /usr/local/bin/pip3.4
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/DESCRIPTION.rst
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/METADATA
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/RECORD
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/WHEEL
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/entry_points.txt
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/metadata.json
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/pbr.json
      Removing file or directory /usr/local/lib/python3.4/dist-packages/pip-6.0.8.dist-info/top_level.txt


  ...
  changing mode of /usr/local/bin/pip to 755
  changing mode of /usr/local/bin/pip3 to 755
  changing mode of /usr/local/bin/pip3.4 to 755
  Cleaning up...
  Exception:
  Traceback (most recent call last):
    File "/usr/lib/python3.4/shutil.py", line 420, in _rmtree_safe_fd
      os.unlink(name, dir_fd=topfd)
  FileNotFoundError: [Errno 2] No such file or directory: 'pip3'

  During handling of the above exception, another exception occurred:

  Traceback (most recent call last):
    File "/usr/local/lib/python3.4/dist-packages/pip/basecommand.py", line 232, in main
      return PREVIOUS_BUILD_DIR_ERROR
    File "/usr/local/lib/python3.4/dist-packages/pip/commands/install.py", line 347, in run
      )
    File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 560, in install
      missing_requested = sorted(
    File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 680, in commit_uninstall
      paths_to_remove.add_pth(easy_install_pth, dist.location)
    File "/usr/local/lib/python3.4/dist-packages/pip/req/req_uninstall.py", line 153, in commit
      self.save_dir = None
    File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 49, in wrapped_f
      return Retrying(*dargs, **dkw).call(f, *args, **kw)
    File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 212, in call
      raise attempt.get()
    File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 247, in get
      six.reraise(self.value[0], self.value[1], self.value[2])
    File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/six.py", line 659, in reraise
      raise value
    File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 200, in call
      attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
    File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 61, in rmtree
      try:
    File "/usr/lib/python3.4/shutil.py", line 464, in rmtree
      _rmtree_safe_fd(fd, path, onerror)
    File "/usr/lib/python3.4/shutil.py", line 402, in _rmtree_safe_fd
      _rmtree_safe_fd(dirfd, fullname, onerror)
    File "/usr/lib/python3.4/shutil.py", line 402, in _rmtree_safe_fd
      _rmtree_safe_fd(dirfd, fullname, onerror)
    File "/usr/lib/python3.4/shutil.py", line 402, in _rmtree_safe_fd
      _rmtree_safe_fd(dirfd, fullname, onerror)
    File "/usr/lib/python3.4/shutil.py", line 422, in _rmtree_safe_fd
      onerror(os.unlink, fullname, sys.exc_info())
    File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 69, in rmtree_errorhandler
      try:
  FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-9lcav3b5-uninstall/usr/local/bin/pip3'

Probably fixed, but maybe others were stumbling into this, so at least it's a "known issue" with that version.

@pwaller
Copy link
Contributor

pwaller commented Oct 12, 2015

We're also encountering this on 7.1.2.

We're running in a docker build context (We've tried both ubuntu 14.04 and 15.04) and I wonder if it might be something to do with that. It's difficult to see why this would happen.

Here's the log:

  Found existing installation: webassets 0.11.dev0
  Uninstalling webassets-0.11.dev0:
  Successfully uninstalled webassets-0.11.dev0
  Exception:
  Traceback (most recent call last):
File "/usr/lib/python3.4/shutil.py", line 419, in _rmtree_safe_fd
  os.unlink(name, dir_fd=topfd)
FileNotFoundError: [Errno 2] No such file or directory: 'test.py'
  During handling of the above exception, another exception occurred:
  Traceback (most recent call last):
File "/usr/local/lib/python3.4/dist-packages/pip/basecommand.py", line 211, in main
  status = self.run(options, args)
File "/usr/local/lib/python3.4/dist-packages/pip/commands/install.py", line 311, in run
  root=options.root_path,
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_set.py", line 657, in install
  requirement.commit_uninstall()
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_install.py", line 729, in commit_uninstall
  self.uninstalled.commit()
File "/usr/local/lib/python3.4/dist-packages/pip/req/req_uninstall.py", line 152, in commit
  rmtree(self.save_dir)
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 49, in wrapped_f
  return Retrying(*dargs, **dkw).call(f, *args, **kw)
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 212, in call
  raise attempt.get()
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 247, in get
  six.reraise(self.value[0], self.value[1], self.value[2])
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/six.py", line 659, in reraise
  raise value
File "/usr/local/lib/python3.4/dist-packages/pip/_vendor/retrying.py", line 200, in call
  attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 90, in rmtree
  onerror=rmtree_errorhandler)
File "/usr/lib/python3.4/shutil.py", line 463, in rmtree
  _rmtree_safe_fd(fd, path, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 401, in _rmtree_safe_fd
  _rmtree_safe_fd(dirfd, fullname, onerror)
File "/usr/lib/python3.4/shutil.py", line 421, in _rmtree_safe_fd
  onerror(os.unlink, fullname, sys.exc_info())
File "/usr/local/lib/python3.4/dist-packages/pip/utils/__init__.py", line 98, in rmtree_errorhandler
  if os.stat(path).st_mode & stat.S_IREAD:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/pip-9f7zqrkb-uninstall/usr/local/lib/python3.4/dist-packages/webassets/test.py'

My current best guess is that something is preventing the file from being created. We're on Docker 1.7.1 and using overlayfs. There is plenty of disk space and there are plenty of free inodes.

@ryukinix
Copy link

ryukinix commented Dec 5, 2015

I have the same problem with building an app with setuptools and after that trying remove with pip:

[lerax@starfox ai-nlp]$ sudo make uninstall
=============
| UNINSTALL |
=============
pip uninstall nlp
Uninstalling nlp-0.15:
  /usr/lib/python3.5/site-packages/nlp-0.15-py3.5.egg
Proceed (y/n)? y
  Successfully uninstalled nlp-0.15
Traceback (most recent call last):
  File "/usr/bin/pip", line 9, in <module>
    load_entry_point('pip==7.1.2', 'console_scripts', 'pip')()
  File "/usr/lib/python3.5/site-packages/pip/__init__.py", line 217, in main
    return command.main(cmd_args)
  File "/usr/lib/python3.5/site-packages/pip/basecommand.py", line 248, in main
    pip_version_check(session)
  File "/usr/lib/python3.5/site-packages/pip/utils/outdated.py", line 102, in pip_version_check
    installed_version = get_installed_version("pip")
  File "/usr/lib/python3.5/site-packages/pip/utils/__init__.py", line 858, in get_installed_version
    working_set = pkg_resources.WorkingSet()
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 629, in __init__
    self.add_entry(entry)
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 685, in add_entry
    for dist in find_distributions(entry, True):
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 2075, in find_eggs_in_zip
    if metadata.has_metadata('PKG-INFO'):
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1605, in has_metadata
    return self.egg_info and self._has(self._fn(self.egg_info, name))
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1963, in _has
    return zip_path in self.zipinfo or zip_path in self._index()
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1843, in zipinfo
    return self._zip_manifests.load(self.loader.archive)
  File "/usr/lib/python3.5/site-packages/pip/_vendor/pkg_resources/__init__.py", line 1783, in load
    mtime = os.stat(path).st_mtime
FileNotFoundError: [Errno 2] No such file or directory: '/usr/lib/python3.5/site-packages/nlp-0.15-py3.5.egg'
Makefile:19: recipe for target 'uninstall' failed
make: *** [uninstall] Error 1

@ncadou
Copy link

ncadou commented Jan 6, 2016

Seeing the same rmtree_errorhandler error with pip 7.1.2 in tox on stock python 2.7, 14.04, and docker 1.9.1 using overlay.

@stewbawka
Copy link

Also, happening to me for trying to upgrade pip from docker environment. using official python2.7 latest

@FragLegs
Copy link

This is definitely a bug in overlay ( see moby/moby#9572 and moby/moby#12327 ). However, since they are dragging their feet on fixing it, I would like to submit a patch that gracefully handles "File Not Found" errors when removing said files. Seems like a harmless thing to let pass, and it would solve a lot of headaches.

@chilicheech
Copy link

I just now started hitting this too while upgrading pip packages in a docker container.

@xavfernandez
Copy link
Member

Yes, apparently there is an issue with overlayfs filesystem, cf moby/moby#9572

@dstufft
Copy link
Member

dstufft commented Mar 24, 2017

Closing this, it appears to have been a kernel bug and that bug is now fixed.

@dstufft dstufft closed this as completed Mar 24, 2017
@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jun 3, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jun 3, 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
Projects
None yet
Development

No branches or pull requests

9 participants