Skip to content

Docs: Clarify that uv run syncs dev dependencies by default and how to prevent it#20521

Open
Joosboy wants to merge 4 commits into
astral-sh:mainfrom
Joosboy:docs/16994-uv-run-sync-production
Open

Docs: Clarify that uv run syncs dev dependencies by default and how to prevent it#20521
Joosboy wants to merge 4 commits into
astral-sh:mainfrom
Joosboy:docs/16994-uv-run-sync-production

Conversation

@Joosboy

@Joosboy Joosboy commented Jul 19, 2026

Copy link
Copy Markdown

Closes #16994.

Adds documentation to the CLI help for uv run and the syncing concepts guide to explicitly call out that uv run automatically syncs development dependencies by default, which can cause them to be inadvertently installed in production environments. Advises users to use --no-dev, --no-sync, or the corresponding environment variables.

Comment thread crates/uv-cli/src/lib.rs
///
/// By default, this environment is synced with development dependencies. To prevent development
/// dependencies from being installed (e.g., in a production environment), use the `--no-dev`
/// flag, use the `--no-sync` flag, or set `UV_NO_DEV=1`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think --no-sync is the right thing to suggest here. Also, let's merge this into the above paragraph

Comment thread crates/uv-cli/src/lib.rs
Comment on lines +1193 to +1195
/// By default, the exported requirements include the project's default dependency groups
/// (such as the standard dependencies and the `dev` group).
///

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?? this seems like an inadvertent change

Comment on lines +545 to +552
## Dynamic metadata

If your project uses dynamic metadata (e.g., to determine the version or dependencies dynamically),
uv may need additional configuration to invalidate its cache when the metadata changes.

See the [caching documentation](../cache.md#dynamic-metadata) for details on configuring cache
invalidation for dynamic metadata.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

irrelevant to this PR

Comment on lines +14 to +21
!!! tip "Syncing in production environments"

Because `uv run` automatically syncs the environment and includes development dependencies by default,
it may inadvertently install development dependencies when used in production.

To avoid this, use the `--no-dev` flag (e.g., `uv run --no-dev ...`), or `--no-sync` if the environment
is already prepared (e.g., via an earlier `uv sync --no-dev`). You can also enforce this by setting `UV_NO_SYNC=1` or `UV_NO_DEV=1` in your environment.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right place to call this out. I'd just remove this part.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better UX and/or documentation to avoid dev dependencies in production

2 participants