uv icon indicating copy to clipboard operation
uv copied to clipboard

error: Cannot uninstall package; RECORD file not found

Open ksamuel opened this issue 1 year ago • 2 comments

Trying to install a package with uv stops because the RECORD file for a dependency package it needs to uninstall does not exist. This means if a command goes wrong, the venv is corrupted for good an can't be fixed without manual intervention.

E.G:

uv pip install wagtail-localize 
Resolved 36 packages in 6ms
error: Cannot uninstall package; RECORD file not found at: /.../.venv/lib/python3.11/site-packages/wagtail-6.0.1.dist-info/RECORD

And indeed /.../.venv/lib/python3.11/site-packages/wagtail-6.0.1.dist-info/ is empty, because some previous uninstallation failed and left the env in a dirty state.

Interestingly, I use only uv on this project, which means it is also responsible for the empty dir. This is another problem to solve but I cannot reproduce it reliably.

Ubuntu 20.04, Python 3.11.8, uv 0.1.11

ksamuel avatar Mar 14 '24 21:03 ksamuel

Hmm, yeah. This is the correct behavior though as described in the spec:

If the RECORD file is missing, tools that rely on .dist-info must not attempt to uninstall or upgrade the package. (This restriction does not apply to tools that rely on other sources of information, such as system package managers in Linux distros.)

I don't know that it's wrong to require some manual intervention in this case -- the environment is broken. (In general, I think virtualenvs should be viewed as completely disposable. Re-creating the virtualenv is effectively free with uv.)

I think the alternative would be that we just ignore the package entirely and overwrite the contents when we go to install, but that also risks leaving your environment in a broken state. We could just proceed-but-warn, I suppose?

charliermarsh avatar Mar 14 '24 22:03 charliermarsh

I can change this to a warning.

charliermarsh avatar Mar 15 '24 03:03 charliermarsh