Skip to main content

uv cache clean

Clear the cache, removing all entries or those linked to specific packages.

Usage

Description

Remove entries from the uv cache. Can remove all cache entries or only those related to specific packages. The cache stores:
  • Downloaded wheels and source distributions
  • Wheels built from source distributions
  • Git repository clones
  • Extracted source distributions
By default, uv cache clean will block until no process is reading the cache. Use --force to bypass this check.

Arguments

[PACKAGE]...

The packages to remove from the cache. If no packages are specified, all cache entries are removed.

Options

--force

Force removal of the cache, ignoring in-use checks. By default, uv cache clean will block until no process is reading the cache. When --force is used, uv cache clean will proceed without taking a lock.
WARNING: Using --force while other uv processes are running may lead to cache corruption or unexpected behavior.

Examples

Remove all cache entries

This will remove all cached packages, wheels, and source distributions. Expected output:

Remove cache for a specific package

Removes all cached versions and builds of numpy. Expected output:

Remove cache for multiple packages

Removes cache entries for multiple packages at once.

Force clean without waiting

Immediately clears the cache without waiting for locks. Use with caution if other uv processes might be running.

Clean specific package with force

Use cases

Free up disk space

The cache can grow large over time. Clean it to reclaim space:

Remove corrupted cache entries

If you encounter cache-related errors:

Reset after configuration changes

After changing Python versions or build settings:

Clean before migration

Before moving or backing up your cache:

CI/CD cache maintenance

In continuous integration, selectively clean cache:

Behavior details

What gets removed

When cleaning a package:
  • All downloaded wheels for that package
  • All source distributions for that package
  • All locally built wheels for that package
  • Git clones if the package is from a Git repository
When cleaning all packages:
  • The entire cache directory is cleared
  • Fresh downloads will be required for all packages

Locking behavior

By default, uv cache clean waits for all other uv processes to finish:
With --force, the lock is bypassed:

Performance impact

After cleaning the cache:
  • First installation of packages will be slower (must download)
  • Subsequent installations will rebuild the cache
  • Building from source will be slower (no cached wheels)

Cache location

The cache is typically located at:
  • Unix/macOS: ~/.cache/uv or $XDG_CACHE_HOME/uv
  • Windows: %LOCALAPPDATA%\uv\cache
To see your cache location:

Comparison with other cache commands

uv cache clean vs uv cache prune

  • uv cache clean: Removes all entries or specific packages
  • uv cache prune: Removes unreachable entries (more granular)

uv cache clean vs rm -rf

Don’t manually delete cache directories:

Notes

  • Cleaning the cache is safe but will slow down subsequent installations
  • The cache automatically manages its size and contents
  • Use uv cache prune for more selective cleaning
  • --force should be used carefully to avoid cache corruption
  • After cleaning, uv will rebuild the cache as packages are installed
  • The cache is global and shared across all projects