question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Poetry 1.2 lockfiles can't always be installed by Poetry 1.1

See original GitHub issue

For version details etc, see repro below.

Issue

Poetry 1.2 can create lockfiles that aren’t installable by Poetry 1.1 due to different handling of . characters in dependency names.

If the configured repository uses the “simple” repository API, Poetry 1.2 replaces . characters with - characters in the name field of dependencies in the lockfile. Poetry 1.1 fails to install from this lockfile with a SolverProblemError.

I’m not sure what guarantees, if any, Poetry makes about lockfile compatibility between Poetry versions. This isn’t a “breaking” change, as such, but makes interoperability painful in cases where the Poetry version can’t be upgraded “atomically”. It might be that this just isn’t supported, in which case a “fix” might be a quick note in the changelog or something.

I’ve got a Docker-based repro using ruamel.yaml:

# syntax=docker/dockerfile:1.3-labs
FROM python:3.8 as poetry1.2
RUN pip install poetry==1.2.1
COPY <<"EOF" /src/pyproject.toml
[tool.poetry]
name = "dotdash"
version = "0.1.0"
description = ""
authors = [""]

[tool.poetry.dependencies]
python = "^3.8"
"ruamel.yaml" = "*"

[[tool.poetry.source]]
name = 'simple'
url = 'https://pypi.org/simple'
default = true

EOF
RUN cd /src && poetry lock

FROM python:3.8 as poetry1.1
RUN pip install poetry==1.1.15
COPY --from=poetry1.2 /src/ /src/
RUN cd /src && poetry install

which produces:

 => ERROR [poetry1.1 4/4] RUN cd /src && poetry install                                                         1.9s
------
 > [poetry1.1 4/4] RUN cd /src && poetry install:
#15 0.995 Creating virtualenv dotdash-VsnhxLU2-py3.8 in /root/.cache/pypoetry/virtualenvs
#15 1.569 Installing dependencies from lock file
#15 1.706
#15 1.706   SolverProblemError
#15 1.706
#15 1.706   Because dotdash depends on ruamel.yaml (*) which doesn't match any versions, version solving failed.
#15 1.706
#15 1.707   at /usr/local/lib/python3.8/site-packages/poetry/puzzle/solver.py:241 in _solve
#15 1.732       237│             packages = result.packages
#15 1.732       238│         except OverrideNeeded as e:
#15 1.732       239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
#15 1.733       240│         except SolveFailure as e:
#15 1.733     → 241│             raise SolverProblemError(e)
#15 1.733       242│
#15 1.733       243│         results = dict(
#15 1.733       244│             depth_first_search(
#15 1.734       245│                 PackageNode(self._package, packages), aggregate_package_nodes

Ignore the non-standard install method for Poetry - I’ve also tested with the recommended method, I’m just being lazy in the Dockerfile.

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:2
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
neersightedcommented, Oct 9, 2022

@vito-c That sounds like a different issue entirely unrelated to the one here. You likely have a damaged cache from interrupting Poetry – try blowing away $(poetry config cache-dir)/artifacts and running poetry cache clear --all .. In most cases, installing a lock file generated by Poetry 1.2 with Poetry 1.1 should work just fine; if you’re running in to problems I would suggest joining Discord or starting a discussion so that others can help you determine what the root cause might be.

0reactions
vito-ccommented, Oct 9, 2022

I was unable to get my 1.2.x lock file to run on our build server that uses 1.1.x Is there any documented workaround? I tried reverting my poetry version to 1.1.x, deleting/resetting my lock file but now everything hangs at Resolving Dependencies...

Read more comments on GitHub >

github_iconTop Results From Across the Web

Announcing Poetry 1.2.0 | Blog
As Poetry 1.1 will remove optional dependencies that are not requested, and as it considers setuptools, pip, and wheel to always be optional, ......
Read more >
tox-poetry-installer - PyPI
A plugin for Tox that lets you install test environment dependencies from the Poetry lockfile.
Read more >
Configure a Poetry environment | PyCharm Documentation
To use Poetry in PyCharm, you need to install it on your machine and create a specific Python environment. Install Poetry. Open Terminal...
Read more >
poetry install | SolverProblemError Because my_project ...
As a general advise I recommend to use poetry's command line instead of creating/manipulating the pyproject.toml . Start with a poetry init ...
Read more >
Dependency Management With Python Poetry
Install dependencies with poetry.lock; Execute basic Poetry CLI commands. Using Poetry will help you start new projects, maintain existing ones, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found