@@ -184,10 +184,9 @@ to remove packages from a specific group:
184
184
poetry remove mkdocs --group docs
185
185
```
186
186
187
-
188
187
## Synchronizing dependencies
189
188
190
- Poetry supports what's called dependency synchronization. What this does is ensuring
189
+ Poetry supports what's called dependency synchronization. Dependency synchronization ensures
191
190
that the locked dependencies in the ` poetry.lock ` file are the only ones present
192
191
in the environment, removing anything that's not necessary.
193
192
@@ -198,7 +197,8 @@ poetry install --sync
198
197
```
199
198
200
199
The ` --sync ` option can be combined with any [ dependency groups] ({{< relref "#dependency-groups" >}}) related options
201
- to synchronize the environment with specific groups.
200
+ to synchronize the environment with specific groups. Note that extras are separate. Any
201
+ extras not selected for install are always removed, regardless of ` --sync ` .
202
202
203
203
``` bash
204
204
poetry install --without dev --sync
@@ -209,3 +209,9 @@ poetry install --only dev
209
209
{{% note %}}
210
210
The ` --sync ` option replaces the ` --remove-untracked ` option which is now deprecated.
211
211
{{% /note %}}
212
+
213
+ ## Layering optional groups
214
+
215
+ When you omit the ` --sync ` option, you can install any subset of optional groups without removing
216
+ those that are already installed. This is very useful, for example, in multi-stage
217
+ Docker builds, where you run ` poetry install ` multiple times in different build stages.
0 commit comments