Skip to content

Instantly share code, notes, and snippets.

@mathomp4
Last active August 11, 2026 18:49
Show Gist options
  • Select an option

  • Save mathomp4/18d74608c8cb91b53664df82f56013e4 to your computer and use it in GitHub Desktop.

Select an option

Save mathomp4/18d74608c8cb91b53664df82f56013e4 to your computer and use it in GitHub Desktop.
Setting up uv on Discover

Setting up uv on Discover

This setup keeps uv, its cache, managed Python installations, and tools on $NOBACKUP storage instead of in your home directory.

Configure uv

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 ~/.bashrc

Install uv

curl -LsSf https://astral.sh/uv/install.sh | \
  sh

Check that the installation is being used:

command -v uv
uv --version

The path should be inside $UV_ROOT/bin, for example:

$NOBACKUP/uv/bin/uv

Update uv

Because uv was installed with the standalone installer, update it with:

uv self update

The UV_INSTALL_DIR setting above keeps the updated executable in $UV_ROOT/bin.

Create a virtual environment

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 venv

This creates a virtual environment in .venv. You can activate it with:

source .venv/bin/activate

Activation is optional. uv automatically detects a .venv in the current directory:

uv pip install PACKAGE_NAME

Replace PACKAGE_NAME with the package or packages you need.

To request a specific Python version, use for example:

uv venv --python 3.12

Managed Python versions are stored under $UV_PYTHON_INSTALL_DIR.

Check and clean the cache

The cache is useful, but it can grow over time. To see its location and remove unused cached data:

uv cache dir
uv cache prune

To remove the entire cache instead:

uv cache clean

See the uv documentation for more information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment