Clarify that uv run uses inexact syncing by default (#17366)

Closes #14230

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Zanie Blue
2026-01-09 07:20:42 -06:00
committed by GitHub
parent 85dedc8051
commit 21f76e8a2a
3 changed files with 22 additions and 6 deletions

View File

@@ -89,17 +89,25 @@ To opt-out of this behavior, use the `--no-editable` option.
If the project does not define a build system, it will not be installed.
See the [build systems](./config.md#build-systems) documentation for details.
### Retaining extraneous packages
### Handling of extraneous packages
Syncing is "exact" by default, which means it will remove any packages that are not present in the
lockfile.
`uv sync` performs "exact" syncing by default, which means it will remove any packages that are not
present in the lockfile.
To retain extraneous packages, use the `--inexact` option:
To retain extraneous packages, use the `--inexact` flag:
```console
$ uv sync --inexact
```
In contrast, `uv run` uses "inexact" syncing by default, ensuring that all required packages are
installed but not removing extraneous packages. To enable exact syncing with `uv run`, use the
`--exact` flag:
```console
$ uv run --exact ...
```
### Syncing optional dependencies
uv reads optional dependencies from the `[project.optional-dependencies]` table. These are

View File

@@ -198,8 +198,14 @@ version.
Prior to every `uv run` invocation, uv will verify that the lockfile is up-to-date with the
`pyproject.toml`, and that the environment is up-to-date with the lockfile, keeping your project
in-sync without the need for manual intervention. `uv run` guarantees that your command is run in a
consistent, locked environment.
in-sync without the need for manual intervention. `uv run` guarantees that your command is run in an
environment with all required dependencies at their locked versions.
!!! note
`uv run` does not remove extraneous packages (those not in the lockfile) from the environment
by default. See [handling of extraneous packages](../concepts/projects/sync.md#handling-of-extraneous-packages)
for details.
For example, to use `flask`:

View File

@@ -88,6 +88,8 @@ document$.subscribe(function () {
"concepts/projects/run/#legacy-scripts-on-windows",
"concepts/projects/sync/#checking-if-the-lockfile-is-up-to-date":
"concepts/projects/sync/#checking-the-lockfile",
"concepts/projects/sync/#retaining-extraneous-packages":
"concepts/projects/sync/#handling-of-extraneous-packages",
"concepts/authentication/#git-authentication":
"concepts/authentication/git/",
"concepts/authentication/#git-credential-helpers":