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

Improve error message for invalid requirements files #6527

Closed
ORESoftware opened this issue May 23, 2019 · 4 comments · Fixed by #6613
Closed

Improve error message for invalid requirements files #6527

ORESoftware opened this issue May 23, 2019 · 4 comments · Fixed by #6613
Labels
auto-locked Outdated issues that have been locked by automation C: requirement file Using `requirements.txt` kind: crash For situations where pip crashes type: bug A confirmed bug or unintended behavior

Comments

@ORESoftware
Copy link

ORESoftware commented May 23, 2019

A pip3 install command is failing with esoteric error message. I am running as the root user on Ubuntu.

  • pip version: pip 9.0.1 from /usr/lib/python3/dist-packages (python 3.6)
  • Python version: Python 3.6.7
  • OS: Ubuntu

I have this:

WORKDIR /apps/datavana/moodwire/mwapi
RUN mkdir -p /pth/to/downloaded/files
RUN mkdir -p /interos/temp
ARG commit

ADD https://bitbucket.org/interos/datavana/raw/"$commit"/moodwire/mwapi/requirements.txt  '/interos/temp/requirements.txt'
ADD https://bitbucket.org/interos/datavana/raw/"$commit"/moodwire/mwapi/constraints.txt '/interos/temp/constraints.txt'

# the ADD commands succeed

RUN pip3 install --cache-dir="/pth/to/downloaded/files" -r /interos/temp/requirements.txt -c /interos/temp/constraints.txt

I get this error:

Step 28/92 : RUN pip3 install --cache-dir="/pth/to/downloaded/files" -r /interos/temp/requirements.txt -c /interos/temp/constraints.txt
 ---> Running in ac48ca1a7f93
Invalid requirement: '<html>'
Traceback (most recent call last):
  File "/usr/share/python-wheels/packaging-17.1-py2.py3-none-any.whl/packaging/requirements.py", line 93, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1632, in parseString
    raise exc
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1622, in parseString
    loc, tokens = self._parse( instring, 0 )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3395, in parseImpl
    loc, exprtokens = e._parse( instring, loc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3717, in parseImpl
    return self.expr._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1379, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 3378, in parseImpl
    loc, resultlist = self.exprs[0]._parse( instring, loc, doActions, callPreParse=False )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 1383, in _parseNoCache
    loc,tokens = self.parseImpl( instring, preloc, doActions )
  File "/usr/share/python-wheels/pyparsing-2.2.0-py2.py3-none-any.whl/pyparsing.py", line 2689, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected W:(abcd...) (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 82, in __init__
    req = Requirement(req)
  File "/usr/share/python-wheels/packaging-17.1-py2.py3-none-any.whl/packaging/requirements.py", line 97, in __init__
    requirement_string[e.loc:e.loc + 8]))
pip._vendor.packaging.requirements.InvalidRequirement: Invalid requirement, parse error at "'<html>'"

The command '/bin/sh -c pip3 install --cache-dir="/pth/to/downloaded/files" -r /interos/temp/requirements.txt -c /interos/temp/constraints.txt' returned a non-zero code: 1

the error message is pretty bad - no matter what's going on.

@uranusjr
Copy link
Member

My gut feeling is that this has nothing to do with pip, but the ADD commands are downloading something different from what you’re expecting. Probably an HTML page instead of the raw text file.

@ORESoftware
Copy link
Author

yeah it was auth problem with bitbucket, getting 403s and html instead of txt files. not sure if the error message could be improved much.

@xavfernandez xavfernandez changed the title pip3 has trouble when installing in non working directory as root Improve error message for invalid requirements files May 24, 2019
@xavfernandez xavfernandez added C: requirement file Using `requirements.txt` kind: crash For situations where pip crashes type: bug A confirmed bug or unintended behavior labels May 24, 2019
@cjerdonek
Copy link
Member

Note that issue #6513 is a similar issue regarding parsing requirement strings and the log message not containing enough info. However, it's still different (e.g. different code path).

@cjerdonek
Copy link
Member

I posted PR #6613 for this.

@lock lock bot added the auto-locked Outdated issues that have been locked by automation label Jul 17, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Jul 17, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
auto-locked Outdated issues that have been locked by automation C: requirement file Using `requirements.txt` kind: crash For situations where pip crashes type: bug A confirmed bug or unintended behavior
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants