LinuxCommandLibrary

conda-clean

Clean unused conda packages and caches

TLDR

Delete all temporary or unused files verbosely and say yes to all confirmations

$ conda clean [[-avy|--all --verbose --yes]]
copy

Delete only index cache, tarballs, and log files
$ conda clean [[-itl|--index-cache --tarballs --logfiles]]
copy

Delete only temporary [c]ache files that could not be deleted earlier due to being in use
$ conda clean [[-c|--tempfiles]] [path/to/tempfiles]
copy

Delete only unused packages. Might delete packages installed with softlinks
$ conda clean [[-p|--packages]]
copy

Force delete all writable packages. More broad than the --all option. Will delete packages installed with softlinks
$ conda clean [[-f|--force-pkgs-dirs]]
copy

Display help
$ conda clean [[-h|--help]]
copy

SYNOPSIS

conda clean [-h] [-y] [--all] [--index-cache] [--packages] [--tarballs] [--logfiles] [--tempfiles] [--dry-run]

PARAMETERS

-h, --help
    Show the help message and exit.

-y, --yes
    Do not ask for confirmation before removing files.

--all
    Remove all unused packages, tarballs, index cache, log files, and temporary files. This is a comprehensive cleaning option.

--index-cache
    Remove the index cache files. These are metadata files downloaded from Conda channels.

--packages
    Remove unused cached packages. These are packages that are no longer linked into any active Conda environment.

--tarballs
    Remove downloaded package tarballs from the Conda cache. Reinstalling these packages will require re-downloading them.

--logfiles
    Remove Conda's log files.

--tempfiles
    Remove temporary files created by Conda operations.

--dry-run
    Perform a dry run. Show what would be removed without actually deleting any files.

DESCRIPTION

The conda clean command is an essential utility for managing disk space used by the Conda package manager. Over time, Conda accumulates various files such as downloaded package tarballs, cached index data, temporary files, and unlinked packages from previous installations or updates. These files, while sometimes useful for reproducibility or offline installations, can consume significant amounts of disk space, especially in environments with frequent package installations, updates, or numerous Conda environments.

conda clean allows users to selectively remove these superfluous files, helping to reclaim valuable disk space. It provides options to target specific categories of files, such as tarballs (downloaded package archives), packages (unused package caches not linked into any environment), index-cache (metadata for package channels), logfiles, and tempfiles. Using this command regularly is a good practice for maintaining efficient Conda installations and preventing disk space exhaustion.

CAVEATS

While conda clean is generally safe, especially when targeting tarballs or index-cache, using options like --packages or --all should be understood. Removing unused packages (not linked to any current environment) is usually fine, but it means that if you later create a new environment or need an older package version, Conda might need to re-download or re-solve dependencies. The --dry-run option is highly recommended to preview changes before permanent deletion, especially when using aggressive cleaning options.

DISK SPACE RECOVERY TIPS

Using conda clean can free up significant amounts of disk space, often several gigabytes, especially on systems where Conda has been used extensively. Prioritize cleaning --tarballs and --packages for maximum impact. Regularly running conda clean --dry-run can help users identify potential space savings without commitment.

IMPACT ON OFFLINE USE

Removing --tarballs can affect offline installations. If you rely on Conda for installations in environments without internet access, you might prefer not to remove tarballs, or to back them up. However, for typical online usage, removing tarballs is a safe and effective way to free up space.

HISTORY

conda clean has been a fundamental utility within the Conda package manager since its early days. As Conda's capabilities expanded to manage complex environments and package dependencies, the need for efficient disk space management grew in parallel. The command's core functionality—to identify and remove transient or unused files—has remained consistent, evolving alongside Conda's development to ensure a robust and user-friendly experience for managing software environments. Its continuous presence underscores its importance in the Conda ecosystem.

SEE ALSO

conda(1), conda create(1), conda install(1), conda remove(1), df(1)

Copied to clipboard