Closed Bug 1709387 Opened 5 years ago Closed 4 years ago

Uninstalling pip package caused WindowsError

Categories

(Firefox Build System :: MozillaBuild, defect)

defect

Tracking

(Not tracked)

RESOLVED WORKSFORME

People

(Reporter: mhentges, Unassigned)

Details

Uninstalling mercurial has put pip in a "strange" state:

$ pip uninstall mercurial
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Found existing installation: mercurial 5.7
Uninstalling mercurial-5.7:
  Would remove:
    c:\mozilla-build\python\lib\site-packages\hgdemandimport\*
    c:\mozilla-build\python\lib\site-packages\hgext3rd\*
    c:\mozilla-build\python\lib\site-packages\hgext\*
    c:\mozilla-build\python\lib\site-packages\mercurial-5.7.dist-info\*
    c:\mozilla-build\python\lib\site-packages\mercurial\*
    c:\mozilla-build\python\lib\site-packages\python27.dll
    c:\mozilla-build\python\scripts\hg
    c:\mozilla-build\python\scripts\hg.exe
Proceed (y/n)? y
  Successfully uninstalled mercurial-5.7
ERROR: Exception:
Traceback (most recent call last):
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\cli\base_command.py", line 223, in _main
    status = self.run(options, args)
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\commands\uninstall.py", line 93, in run
    uninstall_pathset.commit()
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 459, in commit
    self._moved_paths.commit()
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\req\req_uninstall.py", line 299, in commit
    save_dir.cleanup()
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\utils\temp_dir.py", line 207, in cleanup
    rmtree(ensure_text(self._path))
  File "c:\mozilla-build\python\lib\site-packages\pip\_vendor\retrying.py", line 49, in wrapped_f
    return Retrying(*dargs, **dkw).call(f, *args, **kw)
  File "c:\mozilla-build\python\lib\site-packages\pip\_vendor\retrying.py", line 212, in call
    raise attempt.get()
  File "c:\mozilla-build\python\lib\site-packages\pip\_vendor\retrying.py", line 247, in get
    six.reraise(self.value[0], self.value[1], self.value[2])
  File "c:\mozilla-build\python\lib\site-packages\pip\_vendor\retrying.py", line 200, in call
    attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
  File "c:\mozilla-build\python\lib\site-packages\pip\_internal\utils\misc.py", line 142, in rmtree
    onerror=rmtree_errorhandler)
  File "c:\mozilla-build\python\lib\shutil.py", line 270, in rmtree
    rmtree(fullname, ignore_errors, onerror)
  File "c:\mozilla-build\python\lib\shutil.py", line 275, in rmtree
    onerror(os.remove, fullname, sys.exc_info())
  File "c:\mozilla-build\python\lib\shutil.py", line 273, in rmtree
    os.remove(fullname)
WindowsError: [Error 5] Access is denied: u'c:\\mozilla-build\\python\\lib\\site-packages\\~ercurial\\cext\\base85.pyd'

pip list shows -ercurial instead of mercurial:

$ pip list
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
Package    Version
---------- -------
-ercurial  5.7
pip        20.3.4
setuptools 41.4.0
virtualenv 16.7.5

Attempting to uninstall again fails:

$ pip uninstall mercurial
DEPRECATION: Python 2.7 reached the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 is no longer maintained. pip 21.0 will drop support for Python 2.7 in January 2021. More details about Python 2 support in pip can be found at https://pip.pypa.io/en/latest/development/release-process/#python-2-support pip 21.0 will remove support for this functionality.
WARNING: Skipping mercurial as it is not installed.

$ pip uninstall "-ercurial"

Usage:
  pip uninstall [options] <package> ...
  pip uninstall [options] -r <requirements file> ...

no such option: -e

Unsure what's happening here, or what the repercussions are, but it's worth tracking.

Hmm, perhaps this is because my IDE was using mercurial at the time.
The files that failed to be removed are in a directory starting with ~:

README.txt                   setuptools/                  ~ercurial/
easy_install.py              setuptools-41.4.0.dist-info/ ~ercurial-5.7.dist-info/
easy_install.pyc             virtualenv-16.7.5.dist-info/ ~gdemandimport/
pip/                         virtualenv.py                ~gext/
pip-20.3.4.dist-info/        virtualenv.pyc               ~gext3rd/
pkg_resources/               virtualenv_support/

$ rm -r /c/mozilla-build/python/lib/site-packages/~ercurial*
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext\base85.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext\bdiff.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext\mpatch.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext\osutil.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext\parsers.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\cext": The directory is not empty.
"c:\mozilla-build\python\lib\site-packages\~ercurial\thirdparty\sha1dc.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial\thirdparty": The directory is not empty.
"c:\mozilla-build\python\lib\site-packages\~ercurial\zstd.pyd": Access is denied.
"c:\mozilla-build\python\lib\site-packages\~ercurial": The directory is not empty.

Closing my IDE and attempting to rm the dir again succeeded.

I can't repro this anymore, we can re-open if this becomes a problem again.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → WORKSFORME
Product: mozilla.org → Firefox Build System
You need to log in before you can comment on or make changes to this bug.