I'm getting this error `ValueError: Invalid requir...
# development
n
I'm getting this error
ValueError: Invalid requirement '//3rdparty/python:pytest': Parse error at "'//3rdpar'": Expected W:(0-9A-Za-z)
running
test
with coverage
./pants test --test-use-coverage src/python/pants/backend/docker/:
in the pants repo. If I comment out this line, it works 😕
b
Oh, how annoying. Has this previously worked for you and started failing recently?
h
Hmm this is likely a bug in the logic that tries to distinguish between a pip requirement string and a target address, lemme look
But no, the
//
prefix should take care of that
What is the full stack trace to that error?
n
@broad-processor-92400 first time I've tried it in a long time I tried deleting
~/.cache/pants
just now, but it still occurs
Copy code
./pants test --test-use-coverage src/python/pants/backend/docker/:
There is no pantsd metadata at /Users/rhys.madigan/repos/pants/.pids/d54692e05ced/pantsd.
18:17:49.39 [INFO] waiting for pantsd to start...
18:17:49.60 [INFO] pantsd started
18:17:56.46 [INFO] Initializing scheduler...
18:18:07.55 [INFO] Scheduler initialized.
18:18:18.58 [ERROR] 1 Exception encountered:

Engine traceback:
  in select
    ..
  in pants.core.goals.test.run_tests
    `test` goal

Traceback (most recent call last):
  File "/Users/rhys.madigan/.cache/pants/pants_dev_deps/5709c1a054ca5899853199a432062f92bb7571eb.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 102, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/Users/rhys.madigan/.cache/pants/pants_dev_deps/5709c1a054ca5899853199a432062f92bb7571eb.venv/lib/python3.9/site-packages/pkg_resources/_vendor/pyparsing/core.py", line 1141, in parse_string
    raise exc.with_traceback(None)
pkg_resources._vendor.pyparsing.exceptions.ParseException: Expected W:(0-9A-Za-z), found '/'  (at char 0), (line:1, col:1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/pip_requirement.py", line 21, in parse
    return cls(pkg_resources.Requirement.parse(line))
  File "/Users/rhys.madigan/.cache/pants/pants_dev_deps/5709c1a054ca5899853199a432062f92bb7571eb.venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3147, in parse
    req, = parse_requirements(s)
  File "/Users/rhys.madigan/.cache/pants/pants_dev_deps/5709c1a054ca5899853199a432062f92bb7571eb.venv/lib/python3.9/site-packages/pkg_resources/__init__.py", line 3102, in __init__
    super(Requirement, self).__init__(requirement_string)
  File "/Users/rhys.madigan/.cache/pants/pants_dev_deps/5709c1a054ca5899853199a432062f92bb7571eb.venv/lib/python3.9/site-packages/pkg_resources/_vendor/packaging/requirements.py", line 104, in __init__
    raise InvalidRequirement(
pkg_resources.extern.packaging.requirements.InvalidRequirement: Parse error at "'//3rdpar'": Expected W:(0-9A-Za-z)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/Users/rhys.madigan/repos/pants/src/python/pants/core/goals/test.py", line 889, in run_tests
    results = await MultiGet(
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 361, in MultiGet
    return await _MultiGet(tuple(__arg0))
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 168, in __await__
    result = yield self.gets
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/goals/pytest_runner.py", line 503, in run_python_tests
    setup = await Get(
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 118, in __await__
    result = yield self
  File "/Users/rhys.madigan/repos/pants/src/python/pants/engine/internals/selectors.py", line 626, in native_engine_generator_send
    res = rule.send(arg) if err is None else rule.throw(throw or err)
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/goals/pytest_runner.py", line 373, in setup_pytest_for_target
    await validate_pytest_cov_included(pytest)
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/goals/pytest_runner.py", line 220, in validate_pytest_cov_included
    requirements = {PipRequirement.parse(req) for req in _pytest.requirements}
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/goals/pytest_runner.py", line 220, in <setcomp>
    requirements = {PipRequirement.parse(req) for req in _pytest.requirements}
  File "/Users/rhys.madigan/repos/pants/src/python/pants/backend/python/pip_requirement.py", line 49, in parse
    raise ValueError(f"Invalid requirement '{line}'{origin_str}: {e}")
ValueError: Invalid requirement '//3rdparty/python:pytest': Parse error at "'//3rdpar'": Expected W:(0-9A-Za-z)
h
Well, this is a new feature
Oh I see the bug
dammit
@nutritious-hair-72580 can you file an issue?
I'll bang out a fix ASAP
n
Glad you found it! Here's the issue - https://github.com/pantsbuild/pants/issues/19348
h
Commented with a possible workaround