Skip to content

Solver breaks with related dependencies that are both conditional #5506

@anthonymichaelclark

Description

@anthonymichaelclark
  • I am on the latest Poetry version.

  • I have searched the issues of this repo and believe that this is not a duplicate.

  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

  • OS version and name: macOS Monterey 12.3.1

  • Poetry version: 1.1.13

  • Link of a Gist with the contents of your pyproject.toml file: Here

Issue

The solver breaks when faced with dependencies A and B that are both conditional but where A depends on B only sometimes.

Consider these lines from the attached pyproject.toml

dbt = { version = "0.19.2", markers = "sys_platform != 'darwin'" }
dbt-bigquery = [
    { version = "0.19.2", markers = "sys_platform != 'darwin'" },
    { version = "^1.0.0", markers = "sys_platform == 'darwin' "},
]

The intent here is "Install dbt==0.19.2 and dbt-bigquery==0.19.2 when sys_platform is not 'darwin'; else install dbt-bigquery==^1.0.0. When trying to install on a machine using sys_platform == 'darwin' I get:

Updating dependencies
Resolving dependencies... (12.4s)

  SolverProblemError

  Because analytics-dbt depends on dbt (0.19.2) which depends on dbt-bigquery (0.19.2), dbt-bigquery is required.
  So, because analytics-dbt depends on dbt-bigquery (^1.0.0), version solving failed.

  at /opt/homebrew/Cellar/poetry/1.1.13/libexec/lib/python3.10/site-packages/poetry/puzzle/solver.py:241 in _solve
      237│             packages = result.packages
      238│         except OverrideNeeded as e:
      239│             return self.solve_in_compatibility_mode(e.overrides, use_latest=use_latest)
      240│         except SolveFailure as e:
    → 241│             raise SolverProblemError(e)
      242│ 
      243│         results = dict(
      244│             depth_first_search(
      245│                 PackageNode(self._package, packages), aggregate_package_nodes

The same error is reached when those pyproject.toml lines are replaced by

dbt = { version = "0.19.2", markers = "sys_platform != 'darwin'" }
dbt-bigquery = { version = "^1.0.0", markers = "sys_platform == 'darwin'" },

By contrast, note that this pyproject.toml:

[tool.poetry]
name = "analytics-dbt"
version = "0.1.0"
description = ""
authors = ["Flex"]

[tool.poetry.dependencies]
python = "^3.7"
dbt = "0.19.2"
dbt-bigquery = "0.19.2"
agate = "1.6.1"
genson = "^1.2.2"

[tool.poetry.dev-dependencies]
ipdb = "^0.13.4"

[build-system]
requires = ["poetry>=0.12"]
build-backend = "poetry.masonry.api"

resolves.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/solverRelated to the dependency resolverkind/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