Misleading remedy for missing RECORD file with --force-reinstall
thegamecracks opened this issue · comments
thegamecracks commented
Description
I was doing a bit of looking around to figure out how --force-reinstall
was handled, and I found this code snippet:
pip/src/pip/_internal/req/req_uninstall.py
Lines 74 to 81 in 46a342b
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
- Go to the site-packages directory, pick a package, and manually remove the RECORD file from its
.dist-info
directory. - Attempt to uninstall that package normally, i.e.
pip uninstall pkg
. - 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
- I agree to follow the PSF Code of Conduct.