What this thread does
Do first: choose poetry install --only main for a fresh production environment.
Short answer
As of November 2026, Poetry 2.5.2 (November 21, 2026) is the stable release listing. Runtime dependencies belong to implicit main; ordinary non-optional development groups are also included by default. --only main selects runtime dependencies. install can layer packages, while sync removes packages not tracked in the lock file (groups, commands).
Choose / don't choose
- Fresh production environment: choose
poetry install --only main; don't assume naming a group dev excludes it by default (groups). - Environment reused from development: choose synchronization to remove packages not tracked in the lock file; don't interpret a successful plain install as proof old tooling was removed (synchronization).
- Optional group: choose
optional = trueand opt in only in development. Don't move packages needed by the running application out of main (groups). - Optional runtime functionality: choose extras; don't use development groups as published package feature switches (group purpose).
Not for: choosing uv or migrating a Poetry project; see uv-or-poetry-for-a-python-project-ci-lockfile-and-poetry-migration.
Settings that matter
| Setting or flag | Value / default | Applies to | Source |
|---|---|---|---|
poetry install --only | main selects runtime dependencies and omits other groups from this install operation | Poetry 2.5 docs | groups |
tool.poetry.group.docs.optional | true marks the docs group optional; non-optional groups are installed by default | Poetry 2.5 docs | optional groups |
poetry sync --only | Select specific dependency groups; sync also removes packages not tracked in the lock file | Poetry 2.5 docs | sync |
--with / --without | Opt in optional groups / exclude groups; without wins over with | Poetry 2.5 docs | commands |
--no-root | Use only for a dependency-only layer; default installation also installs the project's package | Poetry 2.5 docs | install |
poetry lock | Resolve/write the lock without installing; packages already added to the lock file are not updated by default | Poetry 2.5 docs | lock |
Default poetry install includes main plus every non-optional group, excluding optional groups unless requested. Optionality affects installation, not resolution: all groups must resolve compatibly (groups).
Order of operations
1. Put application runtime packages in main. Define tooling under its own group; for example [tool.poetry.group.docs] with optional = true. This is a configuration table, not a flag on each dependency (groups). 2. After editing group definitions or dependency constraints, run poetry lock, review the lockfile changes and retain the manifest/lock together. This does not install packages (lock). 3. Install from that lock into a fresh production environment with poetry install --only main. Include any deliberate runtime extras; sync removes unspecified extras (groups). 4. Inspect the resulting dependency set and run the real application entry point. If a development-named package remains, determine whether main requires it transitively before treating its presence as a selection failure.
Known failures and fixes
| Error (short quote) | Cause | Fix | Source |
|---|
| Dependency resolution fails despite excluding a group | Optional group dependencies are resolved alongside other dependencies | Reconcile conflicting constraints across groups, then lock again | resolution warning |
pawamoy's November 28, 2019 request explains the environment-selection motivation; its proposed syntax is historical. Use the current group tables and commands above.
Missing
- The current docs do not promise that every package called a development tool will disappear: runtime transitive requirements can legitimately retain it. No project lockfile is specified.
- The resolution failure row is a documented failure condition, not a single universal error message.
Checked
2026-11-23: Poetry 2.5.2 release and current group/CLI docs rechecked; pawamoy's dated feature request and the June 2024 deployment discussion retain the 2026-11-12 check. No lock, install or synchronization executed.
Started from a post by @Poetry, packaged by the editor. Original post