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

Exporting requirements raises when the lock file is out of date #349

Closed
cjolowicz opened this issue Apr 25, 2021 · 0 comments · Fixed by #392
Closed

Exporting requirements raises when the lock file is out of date #349

cjolowicz opened this issue Apr 25, 2021 · 0 comments · Fixed by #392
Labels
bug Something isn't working

Comments

@cjolowicz
Copy link
Owner

cjolowicz commented Apr 25, 2021

Poetry appears to write warnings to stdout when exporting the requirements, causing a parse error.

Update: It's likely not Poetry mixing stdout and stderr here. The Nox interface we're using to invoke Poetry does not return these streams separately. It is actually Poetry writing the warning to stdout. And we're already passing stderr=None to keep stderr separately.

See this run from #348 where the lock file was not up to date:

Run nox --force-color --python=3.9
  nox --force-color --python=3.9
  shell: /usr/bin/bash -e {0}
  env:
    NOXSESSION: pre-commit
    pythonLocation: /opt/hostedtoolcache/Python/3.9.4/x64
    LD_LIBRARY_PATH: /opt/hostedtoolcache/Python/3.9.4/x64/lib
nox > Running session pre-commit
nox > Creating virtual environment (virtualenv) using python3.9 in .nox/pre-commit
nox > poetry export --format=requirements.txt --dev --without-hashes
nox > Session pre-commit raised exception RuntimeError('line 1: \'Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.\': Parse error at "\': The lo\'": Expected stringEnd')
Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/packaging/requirements.py", line 113, in __init__
    req = REQUIREMENT.parseString(requirement_string)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/pyparsing.py", line 1955, in parseString
    raise exc
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/pyparsing.py", line 3814, in parseImpl
    raise ParseException(instring, loc, self.errmsg, self)
pyparsing.ParseException: Expected stringEnd, found ':'  (at char 7), (line:1, col:8)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 67, in to_constraint
    requirement = Requirement(requirement_string)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/packaging/requirements.py", line 115, in __init__
    raise InvalidRequirement(
packaging.requirements.InvalidRequirement: Parse error at "': The lo'": Expected stringEnd

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox/sessions.py", line 549, in execute
    self.func(session)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox/_decorators.py", line 53, in __call__
    return self.func(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 42, in wrapper
    function(proxy, *_args, **_kwargs)
  File "/home/runner/work/nox-poetry/nox-poetry/noxfile.py", line 81, in precommit
    session.install(
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 276, in install
    return self.poetry.install(*args, **kwargs)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 144, in install
    requirements = self.export_requirements()
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 210, in export_requirements
    constraints = to_constraints(self.poetry.export())
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 89, in to_constraints
    return "\n".join(_to_constraints())
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 85, in _to_constraints
    constraint = to_constraint(requirement, line)
  File "/opt/hostedtoolcache/Python/3.9.4/x64/lib/python3.9/site-packages/nox_poetry/sessions.py", line 69, in to_constraint
    raise RuntimeError(f"line {line}: {requirement_string!r}: {error}")
RuntimeError: line 1: 'Warning: The lock file is not up to date with the latest changes in pyproject.toml. You may be getting outdated dependencies. Run update to update them.': Parse error at "': The lo'": Expected stringEnd
nox > Session pre-commit failed.
Error: Process completed with exit code 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant