uv/docs
Shunsuke Tsuchiya 39e2e3e74b
Support UV_WORKING_DIRECTORY for setting --directory (#16125)
<!--
Thank you for contributing to uv! To help us out with reviewing, please
consider the following:

- Does this pull request include a summary of the change? (See below.)
- Does this pull request include a descriptive title?
- Does this pull request include references to any relevant issues?
-->

## Summary

<!-- What's the purpose of the change? What does it do, and why? -->

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

<!-- How was it tested? -->

### 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 <contact@zanie.dev>
2025-10-08 08:46:11 -05:00
..
.overrides Add `last updated` for document (#11164) 2025-02-03 22:28:47 -05:00
assets Add GitHub Actions to PyPI trusted publishing example (#15753) 2025-09-17 19:25:17 +02:00
concepts Bump version to 0.9.0 (#16161) 2025-10-07 23:17:42 +00:00
getting-started Bump version to 0.9.0 (#16161) 2025-10-07 23:17:42 +00:00
guides Bump version to 0.9.0 (#16161) 2025-10-07 23:17:42 +00:00
js Split the "Authentication" page into sections (#15575) 2025-08-28 15:45:31 -05:00
pip Add UV_SKIP_WHEEL_FILENAME_CHECK to allow installing invalid wheels (#16046) 2025-09-29 19:54:25 -04:00
reference Support UV_WORKING_DIRECTORY for setting --directory (#16125) 2025-10-08 08:46:11 -05:00
stylesheets Improve visibility of copy and line separator in dark mode (#14987) 2025-07-31 06:50:12 -05:00
.gitignore Add structured documentation (#4426) 2024-06-26 11:28:42 -05:00
index.md Fix PowerShell code blocks (#13511) 2025-05-17 21:06:48 -05:00
requirements-insiders.in Reference the root requirements from the insiders requirements file (#5105) 2024-07-16 09:51:16 -05:00
requirements-insiders.txt Add an llms.txt to uv (#13929) 2025-06-10 07:46:49 -04:00
requirements.in Add an llms.txt to uv (#13929) 2025-06-10 07:46:49 -04:00
requirements.txt Add an llms.txt to uv (#13929) 2025-06-10 07:46:49 -04:00