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
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.
--force while other uv processes are running may lead to cache corruption or unexpected behavior.
Examples
Remove all cache entries
Remove cache for a specific package
Remove cache for multiple packages
Force clean without waiting
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
- 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:
--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/uvor$XDG_CACHE_HOME/uv - Windows:
%LOCALAPPDATA%\uv\cache
Comparison with other cache commands
uv cache clean vs uv cache prune
uv cache clean: Removes all entries or specific packagesuv cache prune: Removes unreachable entries (more granular)
uv cache clean vs rm -rf
Don’t manually delete cache directories:
Related commands
uv cache prune- Remove unreachable cache entriesuv cache dir- Show the cache directoryuv cache size- Show the cache size
Notes
- Cleaning the cache is safe but will slow down subsequent installations
- The cache automatically manages its size and contents
- Use
uv cache prunefor more selective cleaning --forceshould 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