You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
poetry remove leaves a dangling reference in [tool.poetry.extras] when removing an optional dependency, breaking poetry check #11236
When a package that is referenced by [tool.poetry.extras] is removed from [tool.poetry.dependencies] with poetry remove, the command exits 0 but leaves the extra entry behind. The reference is now invalid, and every subsequent poetry check fails with an error until the user edits the file by hand.
$ poetry lock && poetry remove six --lockWriting lock file # exit 0
$ poetry checkError: Cannot find dependency "six" for extra "tools" in main dependencies. # exit 1
The error is raised by poetry-core's configuration validation (factory.py, Cannot find dependency "..." for extra "..." in main dependencies.), which verifies that every entry in [tool.poetry.extras] resolves to a dependency in [tool.poetry.dependencies].
What the user observes
poetry remove reports success (exit 0), so the user has no reason to suspect anything.
The next poetry check (e.g. in CI) fails with a hard error pointing at config the user did not touch in this step.
This is the same "dangling reference left behind by remove" family as the include-group cleanups (#11225, #11230, #11233), but on the [tool.poetry.extras] side.
Suggested fix
When a package is removed from the main group, also drop its references from [tool.poetry.extras] (removing extras that become empty and the section if it becomes empty). Note this is not the same as #10726's proposal to manage extras entries from the CLI: nothing is added here, we only clean up a reference that can no longer be valid because the dependency it points to is gone.
Activity