Skip to content

Commit 197571e

Browse files
docs: clarify install vs update command differences (#10713)
1 parent 7dcacab commit 197571e

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

docs/cli.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -475,14 +475,6 @@ poetry init
475475
The `install` command reads the `pyproject.toml` file from the current project,
476476
resolves the dependencies, and installs them.
477477

478-
{{% note %}}
479-
Normally, you should prefer `poetry sync` to `poetry install` to avoid untracked outdated packages.
480-
However, if you have set `virtualenvs.create = false` to install dependencies into your system environment,
481-
which is discouraged, or `virtualenvs.options.system-site-packages = true` to make
482-
system site-packages available in your virtual environment, you should use `poetry install`
483-
because `poetry sync` will normally not work well in these cases.
484-
{{% /note %}}
485-
486478
```bash
487479
poetry install
488480
```
@@ -493,6 +485,23 @@ This ensures that everyone using the library will get the same versions of the d
493485

494486
If there is no `poetry.lock` file, Poetry will create one after dependency resolution.
495487

488+
{{% note %}}
489+
**When to use `install` vs `update`:**
490+
- Use `poetry install` to install dependencies as specified in `poetry.lock` (or resolve dependencies and create the lock file if it is missing).
491+
This is what you run after cloning a project. For reproducible installs, prefer `poetry sync`,
492+
which also removes packages that are not in the lock file.
493+
- Use `poetry update` when you want to update dependencies to their latest versions (within the constraints from the `pyproject.toml`)
494+
and refresh `poetry.lock`.
495+
{{% /note %}}
496+
497+
{{% note %}}
498+
Normally, you should prefer `poetry sync` to `poetry install` to avoid untracked outdated packages.
499+
However, if you have set `virtualenvs.create = false` to install dependencies into your system environment,
500+
which is discouraged, or `virtualenvs.options.system-site-packages = true` to make
501+
system site-packages available in your virtual environment, you should use `poetry install`
502+
because `poetry sync` will normally not work well in these cases.
503+
{{% /note %}}
504+
496505
If you want to exclude one or more dependency groups for the installation, you can use
497506
the `--without` option.
498507

@@ -1276,7 +1285,14 @@ you should use the `update` command.
12761285
poetry update
12771286
```
12781287

1279-
This will resolve all dependencies of the project and write the exact versions into `poetry.lock`.
1288+
This will resolve all dependencies of the project, write the exact versions into `poetry.lock`,
1289+
and install them into your environment.
1290+
1291+
{{% note %}}
1292+
The `update` command **does not** modify your `pyproject.toml` file. It only updates the
1293+
`poetry.lock` file with the latest compatible versions based on the constraints already
1294+
defined in `pyproject.toml`. To change version constraints, use the `add` command instead.
1295+
{{% /note %}}
12801296

12811297
If you just want to update a few packages and not all, you can list them as such:
12821298

0 commit comments

Comments
 (0)