This setup keeps uv, its cache, managed Python installations, and tools on
$NOBACKUP storage instead of in your home directory.
Add the following to ~/.bashrc:
export UV_ROOT="$NOBACKUP/uv"
export UV_CACHE_DIR="$UV_ROOT/cache"
export UV_PYTHON_CACHE_DIR="$UV_ROOT/cache/python"
export UV_TOOL_DIR="$UV_ROOT/tools"
export UV_PYTHON_INSTALL_DIR="$UV_ROOT/python"
export UV_TOOL_BIN_DIR="$UV_ROOT/bin"
export UV_PYTHON_BIN_DIR="$UV_ROOT/bin"
export UV_INSTALL_DIR="$UV_ROOT/bin"
# Use copies instead of hard links across filesystems.
export UV_LINK_MODE=copy
export PATH="$UV_ROOT/bin:$PATH"Create the directories:
mkdir -p "$UV_ROOT"/{bin,cache,tools,python}Reload the shell configuration:
source ~/.bashrccurl -LsSf https://astral.sh/uv/install.sh | \
shCheck that the installation is being used:
command -v uv
uv --versionThe path should be inside $UV_ROOT/bin, for example:
$NOBACKUP/uv/bin/uv
Because uv was installed with the standalone installer, update it with:
uv self updateThe UV_INSTALL_DIR setting above keeps the updated executable in
$UV_ROOT/bin.
Choose a working directory on project or nobackup storage. The virtual
environment itself should not be created under $HOME, since installed
packages are stored in the virtual environment, not just in the cache:
mkdir -p "$NOBACKUP/uvtest"
cd "$NOBACKUP/uvtest"
uv venvThis creates a virtual environment in .venv. You can activate it with:
source .venv/bin/activateActivation is optional. uv automatically detects a .venv in the current
directory:
uv pip install PACKAGE_NAMEReplace PACKAGE_NAME with the package or packages you need.
To request a specific Python version, use for example:
uv venv --python 3.12Managed Python versions are stored under $UV_PYTHON_INSTALL_DIR.
The cache is useful, but it can grow over time. To see its location and remove unused cached data:
uv cache dir
uv cache pruneTo remove the entire cache instead:
uv cache cleanSee the uv documentation for more information.