This document describes uv's configuration system, which allows users to customize behavior through configuration files, environment variables, and command-line arguments. The system implements a six-layer precedence hierarchy that merges settings from multiple sources using the Combine trait to produce a unified runtime configuration.
For detailed workspace discovery and project metadata handling, see 7.4 Workspace Support For command-line parsing and argument flow, see 2.1 CLI Architecture and Parsing
uv loads and merges configuration from six hierarchical sources, applied in order of increasing precedence (lowest to highest):
/etc/uv/uv.toml crates/uv-settings/src/lib.rs75-88~/.config/uv/uv.toml crates/uv-settings/src/lib.rs47-73uv.toml or [tool.uv] in pyproject.toml crates/uv-settings/src/lib.rs94-118UV_ crates/uv-static/src/env_vars.rs1-130Each source's options override or extend those of a lower-priority source, enabling flexible and precise user control.
Sources: crates/uv/src/lib.rs113-154 crates/uv/src/settings.rs97-162 crates/uv-settings/src/lib.rs27-154
The process of locating configuration files and environment variables follows these steps:
--config-file or sets UV_CONFIG_FILE, uv loads that file exclusively crates/uv-cli/src/lib.rs147-158uv.toml or a pyproject.toml containing [tool.uv] crates/uv-settings/src/lib.rs94-118user_config_dir() crates/uv-settings/src/lib.rs47-52system_config_file() crates/uv-settings/src/lib.rs75-81The global no-config flag (--no-config or UV_NO_CONFIG) disables automatic config discovery crates/uv-cli/src/lib.rs160-165 crates/uv-static/src/env_vars.rs75-78
Sources: crates/uv/src/lib.rs113-115 crates/uv-settings/src/lib.rs47-154 crates/uv-cli/src/lib.rs140-166
pyproject.toml, it masks the [tool.uv] section in pyproject.toml crates/uv-settings/src/lib.rs141-150[tool.uv]pyproject.toml crates/uv-settings/src/settings.rs35-47[project] and uv-specific overrides in [tool.uv] crates/uv-settings/src/settings.rs75-83Sources: crates/uv-settings/src/settings.rs35-83 crates/uv-settings/src/lib.rs120-182
uv represents settings with multiple Rust structs that reflect layers in configuration and progressively merge them.
Options loaded from disk with an Origin (System, User, or Project) crates/uv-settings/src/lib.rs27-28Sources: crates/uv/src/settings.rs79-162 crates/uv-settings/src/lib.rs27-43 crates/uv-settings/src/settings.rs75-101
Combine Trait: Layered Settings MergingThe core concept enabling hierarchical configuration precedence is the Combine trait.
fn combine(self, other: Self) -> Self; crates/uv-settings/src/combine.rs28-42self (higher priority) is merged with other (lower priority) crates/uv-settings/src/combine.rs29-39Option<T>, it generally returns self if Some, otherwise other crates/uv-settings/src/combine.rs84-128| Type | Merge Behavior |
|---|---|
Option<T> | Returns self if Some, else other crates/uv-settings/src/combine.rs84-128 |
Option<Vec<T>> | Concatenates vectors: self elements followed by other elements crates/uv-settings/src/combine.rs129-141 |
BTreeMap<K, Vec<T>> | Merges maps by combining their vectors for matching keys crates/uv-settings/src/combine.rs143-156 |
ConfigSettings | Merges PEP 517 build settings maps crates/uv-settings/src/combine.rs174-183 |
Sources: crates/uv-settings/src/combine.rs28-213
At runtime, GlobalSettings::resolve computes effective settings crates/uv/src/settings.rs97-162
--allow-python-downloads), environment variables (UV_PYTHON_DOWNLOADS), and workspace config crates/uv/src/settings.rs140-148uv_preview::set crates/uv/src/lib.rs154-159Sources: crates/uv/src/settings.rs97-162 crates/uv/src/lib.rs113-159 crates/uv-cli/src/lib.rs178-211
uv supports a rich ecosystem of environment variables mapped via the EnvVars struct crates/uv-static/src/env_vars.rs6-9
| Variable | Description | Source |
|---|---|---|
UV_CONFIG_FILE | Path to a uv.toml file to use for configuration. | crates/uv-static/src/env_vars.rs148 |
UV_NO_CONFIG | Avoid discovering configuration files. | crates/uv-static/src/env_vars.rs155 |
UV_PYTHON | Equivalent to the --python command-line argument. | crates/uv-static/src/env_vars.rs107 |
UV_SYSTEM_PYTHON | Equivalent to the --system command-line argument. | crates/uv-static/src/env_vars.rs102 |
UV_OFFLINE | Equivalent to the --offline command-line argument. | crates/uv-static/src/env_vars.rs32 |
UV_CACHE_DIR | Equivalent to the --cache-dir command-line argument. | crates/uv-static/src/env_vars.rs69 |
RUFF | Path to the Ruff binary used by uv format. | crates/uv-static/src/env_vars.rs24 |
TY | Path to the ty binary used by uv check. | crates/uv-static/src/env_vars.rs28 |
Sources: crates/uv-static/src/env_vars.rs1-130 crates/uv-cli/src/lib.rs151-165
uv uses a JSON schema to define the structure of Options and GlobalOptions uv.schema.json3-6
>=1.2.3) when adding dependencies uv.schema.json7-17Sources: uv.schema.json1-102
Refresh this wiki