Skip to content

Commit 1df95e2

Browse files
committed
Rewrite the Directory Strategies section
1 parent ab18613 commit 1df95e2

File tree

1 file changed

+28
-60
lines changed

1 file changed

+28
-60
lines changed

docs/reference/storage.md

Lines changed: 28 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -6,61 +6,24 @@ uv persists data in several locations on your system.
66

77
uv follows platform conventions (like
88
[XDG](https://specifications.freedesktop.org/basedir-spec/latest/) on Unix) for determining where to
9-
store different types of data.
9+
store different types of data. Generally, it's best to configure these rather than each uv-specific storage location.
1010

11-
Generally, it's best to configure these rather than each uv-specific storage location.
11+
Here's a summary of the locations uv uses on each platform:
1212

13-
### Cache
13+
| Purpose | Unix Default | Windows Default |
14+
|---------|--------------|-----------------|
15+
| Temporary files and caches | `$XDG_CACHE_HOME/uv` or `~/.cache/uv` as a fallback | `%LOCALAPPDATA%\uv\cache` |
16+
| Persistent data | `$XDG_DATA_HOME/uv` or `~/.local/share/uv` as a fallback | `%APPDATA%\uv\data` if exists, otherwise `%APPDATA%\uv` |
17+
| User configuration files | `$XDG_CONFIG_HOME/uv` or `~/.config/uv` as a fallback | `%APPDATA%\uv` |
18+
| System configuration files | `$XDG_CONFIG_DIRS/uv` or `/etc/uv` as a fallback | `%PROGRAMDATA%\uv` |
19+
| Executables | `$XDG_BIN_HOME` or `$XDG_DATA_HOME/../bin` or `~/.local/bin` as a fallback | same as on Unix |
20+
| Environment | `.venv` in the project or workspace directory | same as on Unix |
1421

15-
Storage location for temporary files and caches:
16-
17-
- `$XDG_CACHE_HOME/uv` or `~/.cache/uv` on Unix systems
18-
- `%LOCALAPPDATA%\uv\cache` on Windows
19-
20-
### Data
21-
22-
Storage location for persistent application data:
23-
24-
- `$XDG_DATA_HOME/uv` or `~/.local/share/uv` on Unix systems
25-
- `%APPDATA%\uv\data` on Windows
26-
- `.uv` in the working directory as a fallback
27-
28-
### Config
29-
30-
Storage location for user configuration files:
31-
32-
- `$XDG_CONFIG_HOME/uv` or `~/.config/uv` on Unix systems
33-
- `%APPDATA%\uv` on Windows
34-
35-
For system configuration files:
36-
37-
- `$XDG_CONFIG_DIRS/uv` or `/etc/uv` on Unix systems
38-
- `%PROGRAMDATA%\uv` on Windows
39-
40-
### Executables
41-
42-
Unlike other directory schemes above, uv follows the XDG standard on _all platforms_ by default,
43-
notably including Windows and macOS, as there is no clear alternative location to place executables
44-
on these platforms.
45-
46-
The installation directory is determined by consulting the following environment variables if
47-
they're set:
48-
49-
- `$XDG_BIN_HOME`
50-
- `$XDG_DATA_HOME/../bin`
51-
- `~/.local/bin`
52-
53-
The above can be overridden by an environment variable specific to [tools](#tool-executables) or
54-
[Python executables](#python-executables).
55-
56-
uv itself is also installed in the above folders by [the installer](./installer.md), and it can be
57-
overridden via the `UV_INSTALL_DIR` environment variable.
58-
59-
## Cache
22+
## Caching
6023

6124
uv uses a local cache to avoid re-downloading and re-building dependencies.
6225

63-
By default, the cache is stored in the [cache home](#cache), which can be overridden via command
26+
By default, the cache is stored according to [the table above](#directory-strategies), and can be overridden via command
6427
line arguments, environment variables, or settings as detailed in
6528
[the cache documentation](../concepts/cache.md#cache-directory).
6629

@@ -73,24 +36,24 @@ It is important for performance for the cache directory to be on the same filesy
7336

7437
uv can download and manage Python versions.
7538

76-
By default, Python versions are stored in the [data home](#data) in a `python/` subdirectory, e.g.,
39+
By default, Python versions are stored as persistant data according to [the table above](#directory-strategies), in a `python/` subdirectory, e.g.,
7740
`~/.local/share/uv/python`.
7841

7942
Use `uv python dir` to show the Python installation directory.
8043

8144
Use the `UV_PYTHON_INSTALL_DIR` environment variable to configure the installation directory.
8245

83-
For more details, see the [Python versions documentation](../concepts/python-versions.md).
46+
!!! note
8447

85-
### Python executables
48+
Changing where Python is installed will not be automatically reflected in existing virtual environments; they will keep referring to the old location, and will need to be updated manually (e.g. by re-creating them).
8649

87-
!!! note
50+
For more details on how uv manages Python versions, see the [dedicated documentation page](../concepts/python-versions.md).
8851

89-
This feature is in preview, and is not enabled without `--preview` or `UV_PREVIEW`.
52+
### Python executables
9053

9154
uv also supports adding Python executables to your `PATH`.
9255

93-
By default, Python executables are stored in the [bin home](#executables).
56+
By default, Python executables are stored according to [the table above](#directory-strategies).
9457

9558
Use `uv python dir --bin` to show the Python executable directory.
9659

@@ -100,7 +63,7 @@ Use the `UV_PYTHON_BIN_DIR` environment variable to configure the executable dir
10063

10164
uv can install Python applications as tools using `uv tool install`.
10265

103-
By default, tools are installed in the [data home](#data) under a `tools/` subdirectory, e.g.,
66+
By default, tools are installed as persistant data according to [the table above](#directory-strategies), under a `tools/` subdirectory, e.g.,
10467
`~/.local/share/uv/tools`
10568

10669
Use `uv tool dir` to show the tool installation directory.
@@ -113,28 +76,33 @@ For more details, see the [tools documentation](../concepts/tools.md).
11376

11477
When installing tools, uv will add tools to your `PATH`.
11578

116-
By default, tool executables are stored in the [bin home](#executables).
79+
By default, tool executables are stored according to [the table above](#directory-strategies).
11780

11881
Use `uv tool dir --bin` to show the tool executable directory.
11982

12083
Use the `UV_TOOL_BIN_DIR` environment variable to configure the executable directory.
12184

85+
## uv
86+
87+
uv itself is also installed by [the installer](./installer.md) into the executables folder from [the table above](#directory-strategies), and it can be
88+
overridden via the `UV_INSTALL_DIR` environment variable.
89+
12290
## Configuration
12391

12492
uv's behavior (including most of the storage locations on this page) can be configured through
12593
configuration files stored in standard locations.
12694

127-
Configuration files are located in the [config directories](#config).
95+
Configuration files are located in the corresponding system- or user-specific locations from [the table above](#directory-strategies).
12896

12997
For more details, see the [configuration files documentation](../concepts/configuration-files.md).
13098

13199
## Project environments
132100

133101
uv creates virtual environments for projects to isolate their dependencies.
134102

135-
By default, project virtual environments are created in `.venv` within the project directory.
103+
By default, project virtual environments are created in `.venv` within the project directory, and a workspace's environment is created with the same name in the workspace root.
136104

137-
Use the `UV_PROJECT_ENVIRONMENT` environment variable to override this location.
105+
Use the `UV_PROJECT_ENVIRONMENT` environment variable to override this location, which is should be either an absolute path, or relative to the workspace root.
138106

139107
For more details, see the
140108
[projects environment documentation](../concepts/projects/config.md#project-environment-path).

0 commit comments

Comments
 (0)