Skip to content

Improve error message for invalid requirements files #6527

@ORESoftware

Description

@ORESoftware

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: requirement fileUsing `requirements.txt`auto-lockedOutdated issues that have been locked by automationkind: crashFor situations where pip crashestype: bugA confirmed bug or unintended behavior

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions