Skip to main content
Environment variables provide a way to configure uv’s behavior without modifying configuration files. They take precedence over persistent configuration but are overridden by command-line arguments.

General Configuration

UV_CACHE_DIR

Specify the cache directory location.
UV_CACHE_DIR
string
Path to the cache directory. Overrides the default platform-specific cache location.
Default locations:
  • Unix: $XDG_CACHE_HOME/uv or $HOME/.cache/uv
  • Windows: %LOCALAPPDATA%\uv\cache

UV_CONFIG_FILE

Use a specific configuration file instead of discovering one.
UV_CONFIG_FILE
string
Path to a uv.toml file. When set, uv ignores all discovered configuration files.

UV_NO_CONFIG

Disable all persistent configuration file discovery.
UV_NO_CONFIG
boolean
Set to 1 or true to disable configuration file discovery.

Index Configuration

UV_INDEX

Add an additional package index (equivalent to --index).
UV_INDEX
string
Index URL, optionally with a name prefix: name=url or just url.

UV_DEFAULT_INDEX

Set the default package index, replacing PyPI.
UV_DEFAULT_INDEX
string
Default index URL, optionally with a name prefix: name=url or just url.

UV_INDEX_STRATEGY

Control how uv searches across multiple indexes.
UV_INDEX_STRATEGY
string
default:"first-index"
Index search strategy:
  • first-index: Use first index containing the package (prevents dependency confusion)
  • unsafe-first-match: Prefer first index with compatible version
  • unsafe-best-match: Select best version across all indexes

UV_INDEX_*_USERNAME

Provide username for a named index.
UV_INDEX_<NAME>_USERNAME
string
Username for authentication. <NAME> is the uppercase index name with non-alphanumeric characters replaced by underscores.

UV_INDEX_*_PASSWORD

Provide password or token for a named index.
UV_INDEX_<NAME>_PASSWORD
string
Password or token for authentication. <NAME> follows the same normalization as USERNAME.
Examples:
Index NameUsername VariablePassword Variable
internal-proxyUV_INDEX_INTERNAL_PROXY_USERNAMEUV_INDEX_INTERNAL_PROXY_PASSWORD
azure.artifactsUV_INDEX_AZURE_ARTIFACTS_USERNAMEUV_INDEX_AZURE_ARTIFACTS_PASSWORD
my_registryUV_INDEX_MY_REGISTRY_USERNAMEUV_INDEX_MY_REGISTRY_PASSWORD

Authentication

UV_KEYRING_PROVIDER

Enable keyring provider for credential retrieval.
UV_KEYRING_PROVIDER
string
default:"disabled"
Keyring provider:
  • disabled: No keyring
  • subprocess: Invoke keyring CLI

NETRC

Specify a custom netrc file location.
NETRC
string
Path to netrc file containing credentials. Defaults to ~/.netrc if not set.

UV_NO_HF_TOKEN

Disable automatic Hugging Face authentication.
UV_NO_HF_TOKEN
boolean
Set to 1 to disable Hugging Face token usage.

Project Configuration

UV_PROJECT_ENVIRONMENT

Customize the project virtual environment path.
UV_PROJECT_ENVIRONMENT
string
default:".venv"
Path to the project virtual environment. Relative paths are resolved from the workspace root.
When using an absolute path across multiple projects, the environment will be overwritten. This is primarily intended for CI/Docker environments.

UV_PYTHON_INSTALL_DIR

Override the Python installation directory.
UV_PYTHON_INSTALL_DIR
string
Directory where managed Python versions are installed.
Default: ~/.local/share/uv/python (Unix) or %LOCALAPPDATA%\uv\python (Windows)

UV_PYTHON_BIN_DIR

Override the Python executable directory.
UV_PYTHON_BIN_DIR
string
Directory where Python executables are installed.

Tool Configuration

UV_TOOL_DIR

Customize the tools installation directory.
UV_TOOL_DIR
string
Directory where tools are installed.
Default: ~/.local/share/uv/tools (Unix) or %LOCALAPPDATA%\uv\tools (Windows)

UV_TOOL_BIN_DIR

Customize the tool executable directory.
UV_TOOL_BIN_DIR
string
Directory where tool executables are installed.

Environment Files

UV_ENV_FILE

Load environment variables from dotenv files.
UV_ENV_FILE
string
Path(s) to dotenv files. Multiple paths separated by spaces.

UV_NO_ENV_FILE

Disable dotenv file loading.
UV_NO_ENV_FILE
boolean
Set to 1 to disable loading environment files.

Installation & Upgrades

UV_INSTALL_DIR

Customize where the uv executable is installed.
UV_INSTALL_DIR
string
Directory where uv and uvx executables are installed when using the standalone installer.

UV_NO_MODIFY_PATH

Prevent the installer from modifying PATH.
UV_NO_MODIFY_PATH
boolean
Set to 1 to prevent PATH modifications during installation.

Publishing

UV_PUBLISH_URL

Set the publish URL without modifying project configuration.
UV_PUBLISH_URL
string
URL for publishing packages.

UV_PUBLISH_USERNAME

Provide username for publishing.
UV_PUBLISH_USERNAME
string
Username for package publishing authentication.

UV_PUBLISH_PASSWORD

Provide password or token for publishing.
UV_PUBLISH_PASSWORD
string
Password or token for package publishing authentication.

Preview Features

UV_PREVIEW

Enable all preview features.
UV_PREVIEW
boolean
Set to 1 to enable all preview features.

UV_PREVIEW_FEATURES

Enable specific preview features.
UV_PREVIEW_FEATURES
string
Comma-separated list of preview features to enable.
Available preview features:
  • native-auth: Use system-native credential storage (Keychain/Credential Manager/Secret Service)

Git Configuration

UV_GIT_LFS

Control Git LFS behavior for dependencies.
UV_GIT_LFS
string
Configure Git LFS for all Git sources without explicit LFS setting:
  • auto: Use LFS if available (default)
  • enabled: Require LFS
  • disabled: Never use LFS

Cache Management

UV_LOCK_TIMEOUT

Set timeout for cache lock operations.
UV_LOCK_TIMEOUT
integer
default:"300"
Timeout in seconds for acquiring cache locks. Used by uv cache clean and similar operations.

TLS Configuration

UV_NATIVE_TLS

Use native TLS implementation instead of rustls.
UV_NATIVE_TLS
boolean
Set to true to use system-native TLS.

Examples

CI/CD Environment

Docker Build

Local Development with Multiple Indexes

Airgapped/Offline Environment

Azure DevOps Pipeline

GitHub Actions

Precedence Order

Configuration sources in order of precedence (highest to lowest):
  1. Command-line arguments (e.g., --cache-dir /tmp/cache)
  2. Environment variables (e.g., UV_CACHE_DIR=/tmp/cache)
  3. Project configuration (e.g., pyproject.toml or uv.toml)
  4. User configuration (e.g., ~/.config/uv/uv.toml)
  5. System configuration (e.g., /etc/uv/uv.toml)
  6. Defaults
Example: