From 39e2e3e74be265c6e38f5dc679fad749a2ac3470 Mon Sep 17 00:00:00 2001
From: Shunsuke Tsuchiya <84004458+shunsock@users.noreply.github.com>
Date: Wed, 8 Oct 2025 22:46:11 +0900
Subject: [PATCH] Support `UV_WORKING_DIRECTORY` for setting `--directory`
(#16125)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## Summary
This pull request enables the `--directory` option to accept environment
variable: `UV_DIRECTORY`
### Motivation
Currently, the `--project` option already supports environment
variables, but --directory does not.
The motivation for this change is the same as for the --project option.
When using this option, it’s likely that the project root and the
directory containing the uv project differ. In such cases, allowing
environment variables makes it easier to avoid repeatedly specifying the
directory in commands or task runners.
### Other PRs
- PR for create `--project` option:
https://github.com/astral-sh/uv/pull/12327
## Test Plan
### no auto testing
As with the --project option, no auto tests are included for this
change.
This is because the implementation relies on Clap’s built-in attribute
functionality, and testing such behavior would effectively mean testing
a third-party crate, which would be redundant.
As long as the compiler accepts it, things should work as expected.
### testing manually
i tested manually like [previous pull
request](https://github.com/astral-sh/uv/pull/12327)
```shell
$ cargo build --locked
./target/debug/uv init uv_directory
$ mkdir uv_directory
$ UV_DIRECTORY=uv_directory ./target/debug/uv sync
Using CPython 3.14.0rc3
Creating virtual environment at: .venv
Resolved 1 package in 15ms
Audited in 0.04ms
$ UV_DIRECTORY=uv_directory ./target/debug/uv run main.py
Hello from uv-directory!
$ ./target/debug/uv run main.py
error: Failed to spawn: `main.py`
Caused by: No such file or directory (os error 2)
```
---------
Co-authored-by: Zanie Blue May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command The keyring provider to use for storage of credentials. Only May also be set with the Possible values: May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command The keyring provider to use for storage of credentials. Only May also be set with the Possible values: May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command The keyring provider to use for reading credentials May also be set with the Possible values: May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Require use of uv-managed Python versions. By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions. May also be set with the Whether to load TLS certificates from the platform's native certificate store. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Load environment variables from a May also be set with the Load environment variables from a Can be provided multiple times, with subsequent files overriding values defined in previous files. May also be set with the Perform an exact sync, removing extraneous packages. When enabled, uv will remove any extraneous packages from the environment. By default, Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Create a project for a library. A library is a project that is intended to be built and distributed as a Python package. Require use of uv-managed Python versions. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Add the requirements as editable May also be set with the Add the requirements as editable Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for specific packages to those that were uploaded prior to the given date. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Limit candidate packages to those that were uploaded prior to the given date. May also be set with the Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for specific packages to those that were uploaded prior to the given date. Accepts package-date pairs in the format May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Don't write a new version to the May also be set with the Don't write a new version to the Instead, the version will be displayed. Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Perform a dry run, without writing the lockfile or modifying the project environment. May also be set with the Perform a dry run, without writing the lockfile or modifying the project environment. In dry-run mode, uv will resolve the project's dependencies and report on the resulting changes to both the lockfile and the project environment, but will not modify either. Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Perform a dry run, without writing the lockfile. May also be set with the Perform a dry run, without writing the lockfile. In dry-run mode, uv will resolve the project's dependencies and report on the resulting changes, but will not write the lockfile to disk. Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Limit candidate packages to those that were uploaded prior to the given date. May also be set with the Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for a specific package to those that were uploaded prior to the given date. Accepts package-date pairs in the format [default: 255] Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Limit candidate packages to those that were uploaded prior to the given date. May also be set with the Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for a specific package to those that were uploaded prior to the given date. Accepts package-date pairs in the format Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Require use of uv-managed Python versions. By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions. May also be set with the Whether to load TLS certificates from the platform's native certificate store. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Load environment variables from a May also be set with the Load environment variables from a Can be provided multiple times, with subsequent files overriding values defined in previous files. May also be set with the Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Install the target package in editable mode, such that changes in the package's source directory are reflected without reinstallation May also be set with the Install the target package in editable mode, such that changes in the package's source directory are reflected without reinstallation Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for specific packages to those that were uploaded prior to the given date. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Limit candidate packages to those that were uploaded prior to the given date. May also be set with the Limit candidate packages to those that were uploaded prior to the given date. Accepts both RFC 3339 timestamps (e.g., May also be set with the Limit candidate packages for specific packages to those that were uploaded prior to the given date. Accepts package-date pairs in the format May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Require use of uv-managed Python versions. By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions. May also be set with the Whether to load TLS certificates from the platform's native certificate store. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Require use of uv-managed Python versions. By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions. May also be set with the Whether to load TLS certificates from the platform's native certificate store. May also be set with the Change to the given directory prior to running the command. Relative paths are resolved with the given directory as the base. See Display the concise help for this command May also be set with the Display the concise help for this command Require use of uv-managed Python versions. By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions. May also be set with the Whether to load TLS certificates from the platform's native certificate store.UV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--keyring-provider keyring-provider--keyring-provider native is supported for login, which uses the system keyring via an integration built into uv.UV_KEYRING_PROVIDER environment variable.UV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--keyring-provider keyring-provider--keyring-provider native is supported for logout, which uses the system keyring via an integration built into uv.UV_KEYRING_PROVIDER environment variable.UV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--keyring-provider keyring-providerUV_KEYRING_PROVIDER environment variable.
@@ -308,7 +308,7 @@ uv auth dir [OPTIONS] [SERVICE]
UV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--managed-pythonUV_MANAGED_PYTHON environment variable.--native-tlsUV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--env-file env-file.env file.UV_WORKING_DIRECTORY environment variable.--env-file env-file.env file.UV_ENV_FILE environment variable.--exactuv run will make the minimum necessary changes to satisfy the requirements.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--lib, --library--managed-pythonUV_DEV environment variable.--directory directory--project to only change the project root directory.--editableUV_WORKING_DIRECTORY environment variable.--editable--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packageUV_DEV environment variable.--directory directory--project to only change the project root directory.--exclude-newer exclude-newerUV_WORKING_DIRECTORY environment variable.--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packagePACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.UV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--dry-runpyproject.tomlUV_WORKING_DIRECTORY environment variable.--dry-runpyproject.toml--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--dry-runUV_WORKING_DIRECTORY environment variable.--dry-run--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--dry-runUV_WORKING_DIRECTORY environment variable.--dry-run--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--exclude-newer exclude-newerUV_WORKING_DIRECTORY environment variable.--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packagePACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.--directory directory--project to only change the project root directory.--exclude-newer exclude-newerUV_WORKING_DIRECTORY environment variable.--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packagePACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--managed-pythonUV_MANAGED_PYTHON environment variable.--native-tlsUV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--env-file env-file.env file.UV_WORKING_DIRECTORY environment variable.--env-file env-file.env file.UV_ENV_FILE environment variable.--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--editable, -eUV_WORKING_DIRECTORY environment variable.--editable, -e--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packageUV_DEFAULT_INDEX environment variable.--directory directory--project to only change the project root directory.--exclude-newer exclude-newerUV_WORKING_DIRECTORY environment variable.--exclude-newer exclude-newer2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.UV_EXCLUDE_NEWER environment variable.--exclude-newer-package exclude-newer-packagePACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.UV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--managed-pythonUV_MANAGED_PYTHON environment variable.--native-tlsUV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--managed-pythonUV_MANAGED_PYTHON environment variable.--native-tlsUV_CONFIG_FILE environment variable.--directory directory--project to only change the project root directory.--help, -hUV_WORKING_DIRECTORY environment variable.--help, -h--managed-pythonUV_MANAGED_PYTHON environment variable.--native-tls
May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -3373,7 +3373,7 @@ uv python list [OPTIONS] [REQUEST]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -3465,7 +3465,7 @@ uv python install [OPTIONS] [TARGETS]...--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--force, -fReplace existing Python executables during installation.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--force, -fReplace existing Python executables during installation.
By default, uv will refuse to replace executables that it does not manage.
Implies --reinstall.
--help, -hDisplay the concise help for this command
@@ -3561,7 +3561,7 @@ uv python upgrade [OPTIONS] [TARGETS]...May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--install-dir, -i install-dirThe directory Python installations are stored in.
If provided, UV_PYTHON_INSTALL_DIR will need to be set for subsequent operations for uv to discover the Python installation.
See uv python dir to view the current Python installation directory. Defaults to ~/.local/share/uv/python.
May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -3721,7 +3721,7 @@ uv python pin [OPTIONS] [REQUEST]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--globalUpdate the global Python version pin.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--globalUpdate the global Python version pin.
Writes the pinned Python version to a .python-version file in the uv user configuration directory: XDG_CONFIG_HOME/uv on Linux/macOS and %APPDATA%/uv on Windows.
When a local Python version pin is not found in the working directory or an ancestor directory, this version will be used instead.
--help, -hDisplay the concise help for this command
@@ -3804,7 +3804,7 @@ from the following environment variables, in order of preference:May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -3869,7 +3869,7 @@ uv python uninstall [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--install-dir, -i install-dirThe directory where the Python was installed
May also be set with the UV_PYTHON_INSTALL_DIR environment variable.
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
@@ -3934,7 +3934,7 @@ uv python update-shell [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -4044,7 +4044,7 @@ uv pip compile [OPTIONS]May also be set with the UV_DEFAULT_INDEX environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--emit-build-optionsInclude --no-binary and --only-binary entries in the generated output file
May also be set with the UV_WORKING_DIRECTORY environment variable.
--emit-build-optionsInclude --no-binary and --only-binary entries in the generated output file
--emit-find-linksInclude --find-links entries in the generated output file
--emit-index-annotationInclude comment annotations indicating the index used to resolve each package (e.g., # from https://pypi.org/simple)
--emit-index-urlInclude --index-url and --extra-index-url entries in the generated output file
May also be set with the UV_DEFAULT_INDEX environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--dry-runPerform a dry run, i.e., don't actually install anything but resolve the dependencies and print the resulting plan
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--dry-runPerform a dry run, i.e., don't actually install anything but resolve the dependencies and print the resulting plan
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_EXCLUDE_NEWER environment variable.
--exclude-newer-package exclude-newer-packageLimit candidate packages for specific packages to those that were uploaded prior to the given date.
@@ -4635,7 +4635,7 @@ uv pip install [OPTIONS]UV_DEFAULT_INDEX environment variable.--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--dry-runPerform a dry run, i.e., don't actually install anything but resolve the dependencies and print the resulting plan
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--dry-runPerform a dry run, i.e., don't actually install anything but resolve the dependencies and print the resulting plan
--editable, -e editableInstall the editable package based on the provided local file path
--exactPerform an exact sync, removing extraneous packages.
By default, installing will make the minimum necessary changes to satisfy the requirements. When enabled, uv will update the environment to exactly match the requirements, removing packages that are not included in the requirements.
@@ -4929,7 +4929,7 @@ uv pip uninstall [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--dry-runPerform a dry run, i.e., don't actually uninstall anything but print the resulting plan
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--dry-runPerform a dry run, i.e., don't actually uninstall anything but print the resulting plan
--help, -hDisplay the concise help for this command
--keyring-provider keyring-providerAttempt to use keyring for authentication for remote requirements files.
At present, only --keyring-provider subprocess is supported, which configures uv to use the keyring CLI to handle authentication.
May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--exclude-editableExclude any editable packages from output
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--exclude-editableExclude any editable packages from output
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
@@ -5078,7 +5078,7 @@ uv pip list [OPTIONS]May also be set with the UV_DEFAULT_INDEX environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--editable, -eOnly include editable projects
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--editable, -eOnly include editable projects
--exclude excludeExclude the specified package(s) from the output
--exclude-editableExclude any editable packages from output
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
@@ -5190,7 +5190,7 @@ uv pip show [OPTIONS] [PACKAGE]...May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--files, -fShow the full list of installed files for each package
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--files, -fShow the full list of installed files for each package
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
@@ -5261,7 +5261,7 @@ uv pip tree [OPTIONS][default: 255]
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_EXCLUDE_NEWER environment variable.
--extra-index-url extra-index-url(Deprecated: use --index instead) Extra URLs of package indexes to use, in addition to --index-url.
Accepts either a repository compliant with PEP 503 (the simple repository API), or a local directory laid out in the same format.
@@ -5364,7 +5364,7 @@ uv pip check [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -5507,7 +5507,7 @@ uv venv [OPTIONS] [PATH]May also be set with the UV_DEFAULT_INDEX environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_EXCLUDE_NEWER environment variable.
--exclude-newer-package exclude-newer-packageLimit candidate packages for a specific package to those that were uploaded prior to the given date.
Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_DEFAULT_INDEX environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--exclude-newer exclude-newerLimit candidate packages to those that were uploaded prior to the given date.
Accepts both RFC 3339 timestamps (e.g., 2006-12-02T02:07:43Z) and local dates in the same format (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_EXCLUDE_NEWER environment variable.
--exclude-newer-package exclude-newer-packageLimit candidate packages for a specific package to those that were uploaded prior to the given date.
Accepts package-date pairs in the format PACKAGE=DATE, where DATE is an RFC 3339 timestamp (e.g., 2006-12-02T02:07:43Z) or local date (e.g., 2006-12-02) in your system's configured time zone.
May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--dry-runPerform a dry run without uploading files.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--dry-runPerform a dry run without uploading files.
When enabled, the command will check for existing files if --check-url is provided, and will perform validation against the index if supported, but will not upload any files.
--help, -hDisplay the concise help for this command
--index indexThe name of an index in the configuration to use for publishing.
@@ -5944,7 +5944,7 @@ uv cache clean [OPTIONS] [PACKAGE]...May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--forceForce removal of the cache, ignoring in-use checks.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--forceForce removal of the cache, ignoring in-use checks.
By default, uv cache clean will block until no process is reading the cache. When --force is used, uv cache clean will proceed without taking a lock.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
@@ -6007,7 +6007,7 @@ uv cache prune [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--forceForce removal of the cache, ignoring in-use checks.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--forceForce removal of the cache, ignoring in-use checks.
By default, uv cache prune will block until no process is reading the cache. When --force is used, uv cache prune will proceed without taking a lock.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
@@ -6075,7 +6075,7 @@ uv cache dir [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -6154,7 +6154,7 @@ uv self update [OPTIONS] [TARGET_VERSION]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--dry-runRun without performing the update
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--dry-runRun without performing the update
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
@@ -6214,7 +6214,7 @@ uv self version [OPTIONS]May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
@@ -6266,7 +6266,7 @@ uv generate-shell-completion [OPTIONS]May also be set with the UV_INSECURE_HOST environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--managed-pythonRequire use of uv-managed Python versions.
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--no-managed-pythonDisable use of uv-managed Python versions.
Instead, uv will search for a suitable Python version on the system.
@@ -6312,7 +6312,7 @@ uv help [OPTIONS] [COMMAND]...May also be set with the UV_CONFIG_FILE environment variable.
--directory directoryChange to the given directory prior to running the command.
Relative paths are resolved with the given directory as the base.
See --project to only change the project root directory.
--help, -hDisplay the concise help for this command
+May also be set with the UV_WORKING_DIRECTORY environment variable.
--help, -hDisplay the concise help for this command
--managed-pythonRequire use of uv-managed Python versions.
By default, uv prefers using Python versions it manages. However, it will use system Python versions if a uv-managed Python is not installed. This option disables use of system Python versions.
May also be set with the UV_MANAGED_PYTHON environment variable.
--native-tlsWhether to load TLS certificates from the platform's native certificate store.
diff --git a/docs/reference/environment.md b/docs/reference/environment.md index 5eb75c939..b8d1934ee 100644 --- a/docs/reference/environment.md +++ b/docs/reference/environment.md @@ -560,6 +560,10 @@ created by `uv venv`. Note that `setuptools` and `wheel` are not included in Python 3.12+ environments. +### `UV_WORKING_DIRECTORY` + +Equivalent to the `--directory` command-line argument. + ## Externally defined variables