pip
pip copied to clipboard
`git config --user unset` errors b/c of ambiguous reference to/inconsistent precedence of user configs (`~/.pip/pip.conf` & `~/.config/pip/pip.conf`)
Description
Pip is supposed to work with multiple "uesr configs", notably ~/.pip/pip.conf & ~/.config/pip/pip.conf. However, pip is inconsistent when determining which one to use when running pip config --user unset.
See "How to Reproduce" for setup details.
Reference snippet: https://github.com/pypa/pip/blob/5efa3e83d90b1d64fbf0104d2ba84bef8d7e9648/src/pip/_internal/configuration.py#L181-L194
- The config key check at
L181will pass b/c the key exists in~/.pip/pip.conf - But parser retrieved on
L184is the one for~/.config/pip/pip.conf, which doesn't exist - So
parser.remove_option()will fail withKeyError/NoSectionError
I'm not familiar with pip internals, but this issue suggests other similar precedence issues may exist elsewhere.
Expected behavior
Pip should have found the setting in ~/.pip/pip.conf and removed it, especially since it's the value pip config get global.index-url reads.
Perhaps there should be a way to specify either/all/any of the user configs, but I imagine this could get messy and would probably take some design considerations.
pip version
pip 23.3.1
Python version
Python 3.11.4
OS
Darwin Kernel Version 22.6.0: Wed Jul 5 22:22:05 PDT 2023; root:xnu-8796.141.3~6/RELEASE_ARM64_T6000
How to Reproduce
~/.pip/pip.conf
[global]
index-url = https://foo.com/bar
~/.config exists, but not ~/.config/pip/
Output
$ pip config --user unset global.index-url
ERROR: Fatal Internal error [id=1]. Please report as a bug.
Code of Conduct
- [X] I agree to follow the PSF Code of Conduct.