Minor: Undefined behavior leads to confusing error with --index-url arg.
See original GitHub issueEnvironment
- pip version: 19.2.3
- Python version: 3.8
- OS: Arch Linux
I do not believe this is limited to arch, but it was discovered as such here: https://github.com/SalomonSmeke/rere/issues/5
note: as pointed out by @uranusjr below this is partially fixed in 19.3
Description
A very minor problem, borderline not a bug but simply less than ideal behavior. When using a --index-url with pip install, passing something other than a url causes a confusing error.
This can manifest like in the issue above:
pip install --index-url --user https://test.pypi.org/simple/ reretrieve
when trying to:
pip install --user --index-url https://test.pypi.org/simple/ reretrieve
Expected behavior
An error about how the index url is invalid, not found, or otherwise messed up.
How to Reproduce
- pip install --index-url --user https://test.pypi.org/simple/ reretrieve
Output
$ pip install --index-url --user https://test.pypi.org/simple/ reretrieve
Looking in indexes: --user
Collecting https://test.pypi.org/simple/
Using cached https://test.pypi.org/simple/
ERROR: Cannot unpack file /tmp/pip-unpack-w9t0tixn/simple (downloaded from /tmp/pip-req-build-s5ub6ixa, content-type: text/html; charset=UTF-8); cannot detect archive format
ERROR: Cannot determine archive format of /tmp/pip-req-build-s5ub6ixa.
note: as pointed out by @uranusjr below in 19.3 the output will look a little different.
Edit
I just wanted to clarify that this happens with any bad text input/invalid url, not just --user
and such.
$ pip install --index-url foo https://test.pypi.org/simple/ reretrieve
Looking in indexes: foo
Collecting https://test.pypi.org/simple/
Using cached https://test.pypi.org/simple/
ERROR: Cannot unpack file /tmp/pip-unpack-160ive4r/simple (downloaded from /tmp/pip-req-build-8dw7kt5w, content-type: text/html; charset=UTF-8); cannot detect archive format
ERROR: Cannot determine archive format of /tmp/pip-req-build-8dw7kt5w
I dont blame you if you decide to wontfix
this one, but wanted to make sure it was an intentional decision. thank you in advance for taking a look!
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:6 (5 by maintainers)
Top GitHub Comments
I’m +1 on mentioning
--index-url
in the warning message, assuming it doesn’t make a mess in the code.People can have
--index-url
and--extra-index-url
inrequirements.txt
which may point to directories that don’t always exist, so I would be wary of turning this into a hard failure.Thanks @uranusjr , I have created a PR considering one possible approach. Please take a look 😃