Skip to content

Dangling include-group references after removing empty dependency groups causes poetry command failures #10590

@Wellshh

Description

@Wellshh

Description

This is derived from #10587, original discussion can be found in here: #10587 (comment).

A mimimum example:

# legacy style
# before removal
[tool.poetry]
package-mode = false
[tool.poetry.group.foo.dependencies]
fastapi = "^0.119.0"
[tool.poetry.group.foo]
include-groups = ["bar",]
[tool.poetry.group.bar.dependencies]
redis = "^6.4.0"

# after removal
[tool.poetry.group.foo.dependencies]
fastapi = "^0.119.0"
[tool.poetry.group.foo]
include-groups = ["bar",]

# -------------
# pep735 style
# before removal
[dependency-groups]
bar = ["redis (>=6.4.0,<7.0.0)",]
foo = [
{include-group="bar"},
"fastapi (>=0.119.0,<0.120.0)",
]

# after removal
[dependency-groups]
foo = [
{include-group="bar"},
"fastapi (>=0.119.0,<0.120.0)",
]

For both cases, After removing an empty dependency group bar, running poetry command will fail due to Group 'foo' includes group 'bar' which is not defined.

Analysis

poetry remove would delete all empty dependency groups while leaving the include-group(pep735) or include-groups unchanged.

Proposed Solution

  • Option 1: Do not change the logic, let the user handle this manually by adding the dependency group again before running any command.
  • Option 2: For both formats, delete all include related logic for the deleted group.
  • Option 3: Logic changed but slight difference between two formats:
    - For pep735, delete all include-group for that group.
    - For lecay format, do not delete the group or the include-groups.

Workarounds

Manually edit the pyproject.toml after removal of empty group

Poetry Installation Method

pipx

Operating System

MacOS Tahoe 26.0.1

Poetry Version

Poetry (version 2.2.1)

Poetry Configuration

xx

Python Sysconfig

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

Example pyproject.toml

Poetry Runtime Logs

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/cliRelated to the command linekind/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