Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/conda/conda/llms.txt

Use this file to discover all available pages before exploring further.

Overview

The conda clean command removes unused packages and caches to free up disk space. It can clean cached package tarballs, index files, unused packages, temporary files, and log files.

Syntax

conda clean [options]

Removal Targets

-a, --all
boolean
Remove index cache, lock files, unused cache packages, tarballs, and logfiles.
-i, --index-cache
boolean
Remove index cache.
-p, --packages
boolean
Remove unused packages from writable package caches. WARNING: This does not check for packages installed using symlinks back to the package cache.
-t, --tarballs
boolean
Remove cached package tarballs.
-f, --force-pkgs-dirs
boolean
Remove all writable package caches. This option is not included with the --all flag. WARNING: This will break environments with packages installed using symlinks back to the package cache.
-c, --tempfiles
string
Remove temporary files that could not be deleted earlier due to being in-use. The argument is a path (or list of paths) to the environment(s) where the tempfiles should be found and removed.
-l, --logfiles
boolean
Remove log files.

Output Options

--json
boolean
Report all output as json. Suitable for using conda programmatically.
-v, --verbose
boolean
Can be used multiple times. Once for detailed output, twice for INFO logging, thrice for DEBUG logging, four times for TRACE logging.
-q, --quiet
boolean
Do not display progress bar.
-d, --dry-run
boolean
Only display what would have been done.
-y, --yes
boolean
Sets any confirmation values to ‘yes’ automatically. Users will not be asked to confirm any adding, deleting, backups, etc.

Examples

conda clean --tarballs

Common Use Cases

Cleaning Everything

Remove all cleanable items to maximize space savings:
conda clean --all
This removes:
  • Index cache
  • Lock files
  • Unused cache packages
  • Tarballs
  • Log files

Cleaning Package Tarballs

Remove downloaded package archives (safe operation):
conda clean --tarballs
This frees space while keeping extracted packages intact.

Cleaning Unused Packages

Remove packages not currently used by any environment:
conda clean --packages

Cleaning Index Cache

Remove cached channel index data:
conda clean --index-cache
The index will be rebuilt on the next conda operation.

Previewing Cleanup

See what would be removed without actually removing:
conda clean --all --dry-run

Cleaning with Details

View exactly what is being removed:
conda clean --all --verbose

Cleaning Temporary Files

Remove leftover temporary files from a specific environment:
conda clean --tempfiles ~/anaconda3/envs/myenv
Or from multiple environments:
conda clean --tempfiles ~/anaconda3/envs/env1 --tempfiles ~/anaconda3/envs/env2

Cleaning Log Files

Remove conda operation logs:
conda clean --logfiles

Combining Cleanup Operations

Clean specific targets together:
conda clean --tarballs --index-cache --logfiles

Automated Cleanup

Clean without confirmation prompts (useful in scripts):
conda clean --all --yes

Understanding Package Caches

Conda maintains package caches to speed up environment creation and reduce downloads:
  • Tarballs: Compressed package archives as downloaded from channels
  • Extracted packages: Unpacked packages ready for linking into environments
  • Index cache: Cached channel metadata and package information

Safe vs. Risky Operations

Safe operations:
  • --tarballs: Safe to remove; packages can be re-downloaded
  • --index-cache: Safe to remove; will be rebuilt automatically
  • --logfiles: Safe to remove; removes historical logs
Caution required:
  • --packages: Generally safe but doesn’t detect symlinked packages
  • --force-pkgs-dirs: DANGEROUS; can break environments using symlinks
Using --force-pkgs-dirs will remove ALL package caches and will break environments that use symlinks to the package cache. Use with extreme caution.
The --packages option removes unused packages but does not check for packages installed using symlinks. Most conda installations use hard links or copies, making this safe. However, verify your installation method before using.
Run conda clean --all --dry-run regularly to see how much space you can reclaim without actually making changes.
The --all flag does NOT include --force-pkgs-dirs for safety. You must explicitly use --force-pkgs-dirs if you want to remove all package caches.