It appears that when attempting to uninstall a package that was installed in editable mode, removing it does not work correctly if the lib/python3.7/site-packages/easy-install.pth
file does not exist.
setup.py
file:from setuptools import setup
setup(
name='repro',
version='0.1dev',
)
python3 -m venv env
env/bin/pip install -e .
rm env/lib/python3.7/site-packages/easy-install.pth
env/bin/pip uninstall repro
ERROR: Cannot remove entries from nonexistent file /..../env/lib/python3.7/site-packages/easy-install.pth
The uninstall should complete successfully, removing the .egg-link
, even if the easy-install.pth
file is not found.
In the wild, there is something that happens with our internal setup that causes the egg-link
, to be created, but not the easy-install.pth
file. I'm still trying to track down how this happens. Regardless of this, I believe that pip
should not fail to uninstall when the file easy-install.pth
doesn't exist, as the operation it would have done there would have just removed the entry from the file anyway.
I am happy to provide any further detail if needed. Thanks! :)
Sounds reasonable to me. The error message can continue to exist, but the uninstallation command does not need to fail. (It would help if pip has a mechanism to fail with a specific error code, but if the choice is between 1 and 0, I would prefer 0.)
I can take this issue up and create the PR, but I have a question about the type of changes we want here.
If I understand correctly, we add easy-install.pth
in files to remove here:
https://github.com/pypa/pip/blob/f6b5b40549583b65253b2de5a8ebfc3bf32cb3c1/src/pip/_internal/req/req_uninstall.py#L532
So in order to fix the issue, do we want to stop checking for easy-install.pth here? Or do we check for easy-install.pth but not raise an exception if it isn't found at
We would still want to remove it if possible (and to emit an error message if it does not exist), so I鈥檇 say the latter. I did not read very deep into the implementation though, so there might be another way.
Hi @uranusjr,
Okay, so do we want to emit the error message, but not cause the installation to fail by perhaps wrapping https://github.com/pypa/pip/blob/f6b5b40549583b65253b2de5a8ebfc3bf32cb3c1/src/pip/_internal/req/req_uninstall.py#L532
in a try catch?
Or instead of raising an error at https://github.com/pypa/pip/blob/f6b5b40549583b65253b2de5a8ebfc3bf32cb3c1/src/pip/_internal/req/req_uninstall.py#L588-L592
we can raise a warning using the warnings module, or just log the error and continue
Hi @uranusjr ,
If my above suggestions make sense now, I can go ahead and create a PR for the same
I like the second approach more; it鈥檚 probably enought to logger.warning
the message and move on.
Thanks @uranusjr for the response. I will create a PR to do the same.