Skip to content

Commit 74ab526

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

File tree

1 file changed

+37
-61
lines changed

1 file changed

+37
-61
lines changed

docs/reference/storage.md

Lines changed: 37 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -6,62 +6,26 @@ 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
10+
storage location.
1011

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

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

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
23+
## Caching
6024

6125
uv uses a local cache to avoid re-downloading and re-building dependencies.
6226

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

6731
Use `uv cache dir` to show the current cache directory path.
@@ -73,24 +37,26 @@ It is important for performance for the cache directory to be on the same filesy
7337

7438
uv can download and manage Python versions.
7539

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

7944
Use `uv python dir` to show the Python installation directory.
8045

8146
Use the `UV_PYTHON_INSTALL_DIR` environment variable to configure the installation directory.
8247

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

85-
### Python executables
50+
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).
8651

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

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

9157
uv also supports adding Python executables to your `PATH`.
9258

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

9561
Use `uv python dir --bin` to show the Python executable directory.
9662

@@ -100,7 +66,8 @@ Use the `UV_PYTHON_BIN_DIR` environment variable to configure the executable dir
10066

10167
uv can install Python applications as tools using `uv tool install`.
10268

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

10673
Use `uv tool dir` to show the tool installation directory.
@@ -113,28 +80,37 @@ For more details, see the [tools documentation](../concepts/tools.md).
11380

11481
When installing tools, uv will add tools to your `PATH`.
11582

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

11885
Use `uv tool dir --bin` to show the tool executable directory.
11986

12087
Use the `UV_TOOL_BIN_DIR` environment variable to configure the executable directory.
12188

89+
## uv
90+
91+
uv itself is also installed by [the installer](./installer.md) into the executables folder from
92+
[the table above](#directory-strategies), and it can be overridden via the `UV_INSTALL_DIR`
93+
environment variable.
94+
12295
## Configuration
12396

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

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

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

131105
## Project environments
132106

133107
uv creates virtual environments for projects to isolate their dependencies.
134108

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

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

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

0 commit comments

Comments
 (0)