pip icon indicating copy to clipboard operation
pip copied to clipboard

Misleading remedy for missing RECORD file with --force-reinstall

Open thegamecracks opened this issue 1 year ago • 0 comments

Description

I was doing a bit of looking around to figure out how --force-reinstall was handled, and I found this code snippet: https://github.com/pypa/pip/blob/46a342b4488853880cec62d73771b5870e416116/src/pip/_internal/req/req_uninstall.py#L74-L81 It says that in the event of RECORD not being found, the package should be re-installed using --force-reinstall. However, I couldn't figure out how --force-reinstall would cause pip to skip the uninstallation step where it would fail. As it turns out, testing the suggested instructions resulted in pip failing to uninstall the package.

Expected behavior

I think instead of --force-reinstall, pip should suggest the --ignore-installed option so that it won't try to uninstall the package and lead to the same error message.

pip version

24.0

Python version

3.11.9

OS

Windows 11

How to Reproduce

  1. Go to the site-packages directory, pick a package, and manually remove the RECORD file from its .dist-info directory.
  2. Attempt to uninstall that package normally, i.e. pip uninstall pkg.
  3. Follow the suggested command to reinstall the package.

Output

$ pip uninstall tzdata
Found existing installation: tzdata 2024.1
ERROR: Cannot uninstall tzdata 2024.1, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps tzdata==2024.1'.
$ pip install --force-reinstall --no-deps tzdata==2024.1
Collecting tzdata==2024.1
  Using cached tzdata-2024.1-py2.py3-none-any.whl.metadata (1.4 kB)
Using cached tzdata-2024.1-py2.py3-none-any.whl (345 kB)
Installing collected packages: tzdata
  Attempting uninstall: tzdata
    Found existing installation: tzdata 2024.1
ERROR: Cannot uninstall tzdata 2024.1, RECORD file not found. You might be able to recover from this via: 'pip install --force-reinstall --no-deps tzdata==2024.1'.

Code of Conduct

thegamecracks avatar Apr 22 '24 23:04 thegamecracks