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

Buggy dependency resolution with poetry v2 #10237

Open
occasional-contributor opened this issue Mar 1, 2025 · 2 comments
Open

Buggy dependency resolution with poetry v2 #10237

occasional-contributor opened this issue Mar 1, 2025 · 2 comments
Labels
area/solver Related to the dependency resolver impact/backport Requires backport to stable branch kind/bug Something isn't working as expected

Comments

@occasional-contributor
Copy link

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.
@occasional-contributor occasional-contributor added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Mar 1, 2025
@dimbleby
Copy link
Contributor

dimbleby commented Mar 1, 2025

@radoering looks like something screwy in the markers being added as at #9427 (as used by re-resolve = false - and the export plugin).

eg slash has an unconditional dependency on colorama so this set of markers is wrong:

 markers = {main = "implementation_name == \"pypy\"", test = "implementation_name == \"pypy\" and sys_platform == \"win32\""}

the pypy bit has somehow found its way into the main group.

@joaopmatias joaopmatias marked this as a duplicate of #10239 Mar 1, 2025
@radoering radoering added area/solver Related to the dependency resolver impact/backport Requires backport to stable branch and removed status/triage This issue needs to be triaged labels Mar 2, 2025
@radoering
Copy link
Member

There are two different bugs:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/solver Related to the dependency resolver impact/backport Requires backport to stable branch kind/bug Something isn't working as expected
Projects
None yet
Development

No branches or pull requests

3 participants