Skip to content

Buggy dependency resolution with poetry v2 #10237

@occasional-contributor

Description

@occasional-contributor

Description

My repo is here.

  • I created a new project with no dependencies.
  • Then I added pytest as a test group dependency and generated a lock file.
  • Then I added slash as a main dependency and regenerated the lock file.

I am seeing a lot of differences between the lock files. poetry v2 is not locking a lot of sub-dependencies. poetry v1 does this correctly. This looks like a major regression.

To make comparison easier, I exported the lock files as requirements.txt files:

poetry v2 completely noodled the test dependencies when adding slash as a main dependency.

- colorama==0.4.6 ; python_version >= "3.9" and sys_platform == "win32"
+ colorama==0.4.6 ; implementation_name == "pypy" and sys_platform == "win32" and python_version >= "3.9"
- exceptiongroup==1.2.2 ; python_version >= "3.9" and python_version < "3.11"
+ exceptiongroup==1.2.2 ; python_version < "3.11" and implementation_name == "pypy" and python_version >= "3.9"
- iniconfig==2.0.0 ; python_version >= "3.9"
+ iniconfig==2.0.0 ; python_version >= "3.9" and implementation_name == "pypy"
- packaging==24.2 ; python_version >= "3.9"
+ packaging==24.2 ; python_version >= "3.9" and implementation_name == "pypy"
- pluggy==1.5.0 ; python_version >= "3.9"
+ pluggy==1.5.0 ; python_version >= "3.9" and implementation_name == "pypy"
- pytest==8.3.4 ; python_version >= "3.9"
+ pytest==8.3.4 ; python_version >= "3.9" and implementation_name == "pypy"
- tomli==2.2.1 ; python_version >= "3.9" and python_version < "3.11"
+ tomli==2.2.1 ; implementation_name == "pypy" and python_version < "3.11" and python_version >= "3.9"

On the other hand, poetry v1 made no changes to the test dependencies when slash was added to the main dependencies.

The locked dependencies with poetry v2 are also incorrect/incomplete for the same reasons.

Workarounds

Keep using poetry v1.

Poetry Installation Method

pip

Operating System

macOS

Poetry Version

2.1.1

Poetry Configuration

cache-dir = "/Users/user/Library/Caches/pypoetry"
data-dir = "/Users/user/Library/Application Support/pypoetry"
installer.max-workers = null
installer.no-binary = null
installer.only-binary = null
installer.parallel = true
installer.re-resolve = true
keyring.enabled = true
python.installation-dir = "{data-dir}/python"  # /Users/user/Library/Application Support/pypoetry/python
requests.max-retries = 0
solver.lazy-wheel = true
system-git-client = false
virtualenvs.create = true
virtualenvs.in-project = null
virtualenvs.options.always-copy = false
virtualenvs.options.no-pip = false
virtualenvs.options.system-site-packages = false
virtualenvs.path = "{cache-dir}/virtualenvs"  # /Users/user/Library/Caches/pypoetry/virtualenvs
virtualenvs.prompt = "{project_name}-py{python_version}"
virtualenvs.use-poetry-python = false

Python Sysconfig

sysconfig.log
Paste the output of 'python -m sysconfig', over this line.

Example pyproject.toml

[project]
name = "poetry-slash-test"
version = "0.1.0"
description = ""
authors = [
    { name = "Your Name", email = "[email protected]" },
]
readme = "README.md"
requires-python = ">=3.9"

[tool.poetry]
requires-poetry = ">=2.0"
package-mode = false

[tool.poetry.group]

[tool.poetry.group.main.dependencies]
slash = { version = "^1.14" }

[tool.poetry.group.test]
optional = true

[tool.poetry.group.test.dependencies]
pytest = { version = "^8.3.4" }

Poetry Runtime Logs

poetry-runtime.log

logs.txt

Paste the output of 'poetry -vvv <command>', over this line.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/solverRelated to the dependency resolverimpact/backportRequires backport to stable branchkind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions