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

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

Open
1 task done
thegamecracks opened this issue Apr 22, 2024 · 0 comments
Open
1 task done

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

thegamecracks opened this issue Apr 22, 2024 · 0 comments
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior

Comments

@thegamecracks
Copy link

Description

I was doing a bit of looking around to figure out how --force-reinstall was handled, and I found this code snippet:

msg = f"Cannot uninstall {dist}, RECORD file not found."
installer = dist.installer
if not installer or installer == "pip":
dep = f"{dist.raw_name}=={dist.version}"
msg += (
" You might be able to recover from this via: "
f"'pip install --force-reinstall --no-deps {dep}'."
)

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 thegamecracks added S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior labels Apr 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: needs triage Issues/PRs that need to be triaged type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

No branches or pull requests

1 participant