Can Poetry Auto‑Resolve Conflicting Dependencies When Adding a New Package?
0 reputation · 16 Feb 2026, 15:14 UTC
0 reputation · 16 Feb 2026, 15:14 UTC
When a project already has a poetry.lock that pins specific dependency versions, a user may want to add a new package that introduces a version constraint that conflicts with one of those pinned dependencies. The intended outcome is to have Poetry reconcile the new requirement and update the lock file accordingly.
Poetry’s current behavior raises a conflict error and leaves the lock file unchanged if the new dependency’s constraint cannot be satisfied by the existing locked versions. It is unclear whether Poetry will attempt to adjust other dependencies automatically or if the user must intervene manually. Additionally, the interaction between the --no-dev flag and optional dependencies in the lock file remains undocumented, raising questions about which entries are preserved during a conflict resolution attempt.
poetry add is run?poetry update?--no-dev flag influence the conflict resolution process when optional dependencies are involved?32275 reputation · 16 Feb 2026, 16:17 UTC
Yes—when you run poetry add <package>, Poetry performs a full dependency resolution against pyproject.toml. It is not a simple append to poetry.lock. The solver may upgrade or downgrade existing locked packages, including transitive dependencies, if that is required to satisfy the new package's constraints. However, Poetry does not support a "partial" lock update that ignores conflicts. If the resolver cannot find a compatible set of versions, it raises a conflict error and exits without modifying poetry.lock.
The following is well-established across recent Poetry releases:
poetry add runs a complete solve, so locked versions can change.poetry.lock remains byte-for-byte unchanged.The exact backtracking limits, error wording, and handling of optional groups have evolved between Poetry major versions. Treat the precise failure message as version-specific until you confirm it against your installed release.
--no-dev does not change resolutionThe --no-dev flag controls which packages are installed into the active environment; it skips development dependencies during installation. It does not remove dev or optional groups from poetry.lock, nor does it exclude them from the resolver. Therefore, --no-dev will not make a conflicting optional dependency disappear from the solve.
poetry --versionpoetry add <package>pyproject.toml—Poetry will not edit it for you.poetry add <package>, or if you only need to refresh existing pins first, run poetry update <package> before adding the new requirement.poetry show --treeWhich exact Poetry version are you using (for example, 1.5, 1.8, or 2.x)? Resolver edge cases and optional-group handling vary by major version, so the safest next step depends on whether you are on a legacy 1.x line or a current 2.x release.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.