Skip to content
Latchkey

astral-sh/setup-uv

Install uv (the fast Python package manager) with built-in cache upload and restore.

Official actionCategory: Language & Toolchain SetupLatest v8View on GitHub

What it does

astral-sh/setup-uv installs uv so later steps can run uv sync, uv run, or uvx. The version defaults to what is pinned in pyproject.toml, or latest.

It also handles caching of the uv cache directory (enable-cache defaults to auto) and can set the Python version via UV_PYTHON or activate a ready-to-use venv.

Usage

workflow (.yml)
steps:
  - uses: actions/checkout@v4
  - uses: astral-sh/setup-uv@v8
    with:
      python-version: '3.13'
  - run: uv sync --locked
  - run: uv run pytest

Inputs

InputDescriptionDefaultRequired
versionThe version of uv to install, e.g. 0.5.0. Defaults to the version in pyproject.toml or latest.-No
version-fileFile containing the uv version, e.g. uv.toml, pyproject.toml, .tool-versions, uv.lock.-No
python-versionThe version of Python to set UV_PYTHON to.-No
activate-environmentUse uv venv to activate a venv ready to be used by later steps.falseNo
enable-cacheEnable uploading of the uv cache.autoNo
cache-suffixSuffix for the cache key.-No
working-directoryDirectory to execute commands in and look for files such as pyproject.toml.${{ github.workspace }}No

Outputs

OutputDescription
uv-versionThe installed uv version. Useful when using latest.
uv-pathThe path to the installed uv binary.
cache-hitWhether a cache entry was found.
venvPath to the activated venv if activate-environment is true.

Notes

You usually do not need actions/setup-python alongside this action: uv installs and manages Python itself when python-version is set.

Common errors

  • The post-run cache save fails when there is nothing in the uv cache directory (for example, the job never ran a uv command); set ignore-nothing-to-cache: true or make sure a uv command actually runs.
  • uv: command not found in a later step means the setup step did not run first in that job; each job needs its own setup-uv step.

Security and pinning

  • Pin the action to a commit SHA and pin version to an exact uv release; a floating latest changes resolver behavior between runs.

Alternatives and related

Frequently asked questions

Do I still need actions/setup-python with setup-uv?
Generally no. Pass python-version to setup-uv and uv will download and manage the interpreter itself, including caching it when cache-python is enabled.
Why is my uv cache never restored on feature branches?
GitHub Actions cache is scoped by branch: branches can read the default branch cache but not each other's. Make sure a run on the default branch has saved a cache first.
Running astral-sh/setup-uv? Run it on Latchkey managed runners - self-healing and caching included. Start free → 30-day trial · No credit card