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

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.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16 (9 by maintainers)

Commits related to this issue

Most upvoted comments

Version numbers are merely marketing here – if we had bumped the major, like @dimbleby said, this situation would be identical. You would have to use an old version of Poetry that is not receiving fixes to maintain compatibility with an older version of Poetry.

Also, this issue was tracking differences in behavior around the complex interaction between the lock file and the solver across versions; your concerns center solely around the changing of the lock file version, where no backwards compatibility is promised.

In any case, I think that this entire issue is stale due to time. We should probably formally document the versioning we are using (read: Python-ish with incremental change, unlikely to bump major unless the CLI UX experiences a breaking change), but that would be another issue. If you want to open it, I encourage you to 😃

@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.