Written and maintained by CASRAI Editorial Board
Published
On this page
To clear the conda cache, run conda clean --all. According to the official conda documentation, that one command removes the index cache, unused cached packages, package tarballs, temporary files and log files. Add --dry-run first to see what would be removed, and note that --all does not include --force-pkgs-dirs, the flag that wipes every writable package cache and can break environments.
What conda clean is used for in research
Every time conda installs or updates a package it downloads the package as a tarball and keeps a copy in a package cache. The Anaconda team describes this as conda keeping these caches indefinitely, and puts typical savings from cleaning at a few hundred megabytes up to several gigabytes. For analysts who build a new environment for each project, that cache grows quietly, and it is the first place to look when a home directory, a laptop disk or a shared project quota fills up.
There is no command called “clear cache” in conda. The cleanup command is conda clean, and it has separate switches for each kind of leftover: the index cache (the downloaded channel metadata), unused packages, tarballs, temporary files and log files. Knowing which switch does what is the difference between a safe cleanup and one that breaks an environment you still need for a paper.
Two things the Anaconda team states that people often assume otherwise: conda clean does not delete or modify your environments, and it does not remove packages that your environments currently use. It also does not make conda faster. It is a disk-space tool, not a performance tool.
Research projects have a particular reason to be careful. A result is only reproducible if the environment that produced it can be rebuilt, so cleanup should come after the environment is recorded, not instead of recording it. The guide to sharing a reproducible conda environment covers how to capture an environment before you remove anything, and the guide to making a new conda environment covers the per-project pattern that creates the caches in the first place.
How to install or access conda
The conda clean command ships with conda itself, so there is nothing separate to install. The official “Installing conda” page says you pick an installer first: Miniconda and Anaconda Distribution are preconfigured to use the Anaconda Repository, and Miniforge is the third option named there. The same page lists Windows, macOS and Linux as supported operating systems and says no administrator rights are needed if you install to a location you can write to, such as a folder in your home directory. Its minimum disk space is 400 MB for Miniconda or Miniforge and 3 GB for Anaconda, which is worth remembering when you read how much a cache can add on top. The page also recommends checking the installer’s SHA-256 checksum before you run it, using Get-FileHash in PowerShell, shasum -a 256 on macOS or sha256sum on Linux. If you are choosing between channels as well as installers, the conda-forge guide explains that community channel.
To use the command, open a terminal where conda is available. On Windows that is typically the Anaconda Prompt or a shell where conda has been initialised; if your shell reports that conda is not found, the guide to adding conda to your PATH walks through the fix. To see the full list of switches in your installed version, run conda clean --help.
How to clear the conda cache step by step
The order below is the safest sequence the documentation supports. Each step uses a flag described on the official conda clean page.
- Record the environments you care about. Activate an environment and export it with
conda activate myenvthenconda env export > environment.yml, as the official “Managing environments” page shows. That page notes an existingenvironment.ymlin the current directory will be overwritten, so run it in a folder where that is acceptable. - List your environments. Run
conda env listorconda info --envs. This matters because the--packagesflag only checks environments listed byconda info --envsfor symlinks back to the package cache. - Preview the cleanup. Run
conda clean --all --dry-run. The-d/--dry-runflag is documented as “Only display what would have been done”, so nothing is removed. - Run the cleanup. Run
conda clean --all. This removes the index cache, unused cache packages, tarballs, tempfiles and logfiles. Conda asks for confirmation unless you add-y/--yes, which “sets any confirmation values to ‘yes’ automatically”. - Check an environment still works. Activate one of your project environments and import or run something small. Because the command does not delete environments or remove packages they use, this should behave exactly as before.
Clear only one kind of cache
If you want to remove less than --all, use the individual flags. Each one is on the official page:
conda clean --tarballs(or-t) removes cached package tarballs. This is the example command the official page itself shows.conda clean --index-cache(or-i) removes the index cache.conda clean --packages(or-p) removes unused packages from writable package caches.conda clean --logfiles(or-l) removes log files.conda clean --tempfiles path/to/env(or-c) removes temporary files that could not be deleted earlier because they were in use. It takes one or more environment paths, so it is the one switch that needs an argument.
The data table below sets all of these side by side, including the one that --all leaves out.
Why not use –force-pkgs-dirs?
The -f / --force-pkgs-dirs flag is documented as “Remove all writable package caches”, and the page adds a warning that it “will break environments with packages installed using symlinks back to the package cache”. It is deliberately not part of --all. Unless you have a specific reason and know how your environments were installed, leave it alone; a normal cleanup never needs it.
The symlink caution
The Anaconda post and the official page agree on the one real hazard. If your environments are configured to use symlinks to the package cache, take care with --packages and --all. The official --packages help states that environments not listed by conda info --envs are not checked for symlinks back to the cache. In practice this means an environment you created at an unusual path, or one that was moved, may not be protected by the check. Dry-run first, and make sure the environments you care about appear in conda info --envs.
An illustrative scenario
This is an illustrative composite, not a report of a real group. Suppose an analyst has built separate environments for three analyses over a year, and a project directory on a shared drive is close to its quota. They export each environment to a YAML file kept with the project, run conda clean --all --dry-run to see what would go, run conda clean --all to remove it, and then activate one environment to confirm it still imports its packages. They have not touched any environment, so a later rebuild from the YAML files remains possible. They avoided --force-pkgs-dirs because they could not be sure none of the environments used cache symlinks.
How to read the conda clean output
With --dry-run, conda only reports what it would have done, so you can read the output as a list of candidate removals and decide whether to proceed. Without it, conda reports what it removes and asks for confirmation unless you passed --yes. Three options change the way the output is presented:
--jsonreports all output as JSON and is documented as “Suitable for using conda programmatically”. Use it when a script or a pipeline step needs to read the result rather than a person.--consoletakesclassicorjsonand selects the backend used for normal output rendering.-v/--verbosecan be repeated: once gives more detail, twice INFO logging, three times DEBUG logging and four times TRACE logging.-q/--quietturns off the progress bar.
For a record you can keep with a project, conda clean --all --dry-run --json gives a machine-readable preview that can be saved alongside your notes. The conda documentation does not publish a fixed schema for this output on the page cited here, so read the JSON your own version produces before building anything that depends on specific keys.
The effect you should expect is described by the Anaconda team: saved space, no removed environments, and no change in conda’s speed. Judge success by disk usage on the drive that holds your package cache, not by how fast conda runs afterwards. According to the official settings documentation, if pkgs_dirs is not set, envs/pkgs is used as the package cache, except for the standard envs directory in the root directory, for which the normal root_dir/pkgs is used. That tells you where to measure.
Troubleshooting conda clean
conda is not recognised in the terminal
If the shell cannot find conda, the cleanup never starts. Open a shell where conda is initialised or fix your PATH using the PATH guide, then rerun the command.
An environment seems broken after cleanup
The official page names the likely cause: environments with packages installed using symlinks back to the package cache are broken by --force-pkgs-dirs, and --packages does not check environments missing from conda info --envs. If you used either, recreate the environment from the YAML file you exported earlier. The official “Managing environments” page shows conda create --file environment.yml for that, and it notes that conda env create --file also still works but is not the preferred way. Removing a damaged environment first is done with conda env remove --name myenv (or conda remove --name myenv --all).
Disk space did not drop much
Remember that conda clean removes unused cached files and not packages your environments currently use, so the environments themselves keep their space. If you want to reclaim space held by an environment you no longer need, that is an environment removal, which is a separate decision from clearing the cache. The updating guide, how to update conda, is also worth reading: each update or install can add new cached tarballs, so cleaning is a periodic task rather than a one-off.
The temporary-files switch asks for an argument
--tempfiles is the only cleanup switch that expects a path, because it looks for temporary files in specific environments. Pass the environment path, for example conda clean --tempfiles path/to/env. When you use --all, tempfiles are already included.
You want to change where the cache lives
The official settings page says the CONDA_PKGS_DIRS environment variable overwrites the pkgs_dirs setting, for example CONDA_PKGS_DIRS=/opt/anaconda/pkgs on macOS or Linux and set CONDA_PKGS_DIRS=C:Anacondapkgs on Windows. Pointing the cache at a drive with more room is a way to avoid the quota problem instead of cleaning it, but cleaning is still needed for the files already there.
Free alternatives to conda clean
There is no separate free tool needed to clean a conda cache: the cleanup is built into conda, and the Anaconda team describes it as the way to remove unused cached files. What you can choose is how narrow the action is, or whether to manage space in a different way. The table maps common goals to documented commands.
| Goal | Command | Documented effect |
|---|---|---|
| Preview any cleanup without removing anything | conda clean --all --dry-run |
Only displays what would have been done |
| Remove only downloaded package files | conda clean --tarballs |
Removes cached package tarballs |
| Remove only cached channel metadata | conda clean --index-cache |
Removes the index cache |
| Remove a whole environment you no longer need | conda env remove --name myenv |
Removes the named environment (alternative: conda remove --name myenv --all) |
| Move the package cache elsewhere | CONDA_PKGS_DIRS |
Overwrites the pkgs_dirs setting |
| Keep a rebuildable record before cleaning | conda env export > environment.yml |
Writes the active environment to a YAML file |
For work that must be repeated years later, the best habit is to treat the package cache as disposable and the exported environment file as the thing to keep. That keeps the cleanup low-risk, because the files that conda clean removes are regenerated when an environment is rebuilt.
Sources
- Conda documentation: conda clean, checked 2026-11-18
- Conda documentation: Settings (pkgs_dirs and CONDA_PKGS_DIRS), checked 2026-11-18
- Conda documentation: Managing environments, checked 2026-11-18
- Conda documentation: Installing conda, checked 2026-11-18
- Anaconda: When was the last time you checked how much disk space conda is using?, checked 2026-11-18
Data: conda clean removal flags compared
Compares each removal flag of the conda clean command: its short form, what it removes, whether the --all option includes it, and the warning the documentation attaches. Compiled from the conda documentation page for conda clean and the Anaconda post on conda disk usage, read 2026-11-18.
| Flag | Short form | What it removes | Included in --all | Documented caution |
|---|---|---|---|---|
| --all | -a | Index cache, unused cache packages, tarballs, tempfiles, logfiles | Not applicable | Take care if environments use symlinks to the package cache (Anaconda post) |
| --index-cache | -i | Index cache | Yes | None stated on the page |
| --packages | -p | Unused packages from writable package caches | Yes | Environments not listed by conda info --envs are not checked for symlinks back to the cache |
| --tarballs | -t | Cached package tarballs | Yes | None stated on the page |
| --force-pkgs-dirs | -f | All writable package caches | No | Breaks environments with packages installed using symlinks back to the package cache |
| --tempfiles PATH | -c | Temporary files that could not be deleted earlier because they were in use | Yes | Takes one or more environment paths as its argument |
| --logfiles | -l | Log files | Yes | None stated on the page |
Sources
- Conda documentation: conda clean (accessed 2026-11-18)
- Anaconda: When was the last time you checked how much disk space conda is using? (accessed 2026-11-18)
Compiled by CASRAI from the sources above. Free to reuse under CC BY 4.0 with attribution.







