Is it safe to delete conda’s pkgs folder and old environments?
- Yes, through conda.
conda clean --allremoves cached packages no environment uses, along with tarballs, index caches and logs. Deletingpkgsby hand can break environments that link back to it, so don’t. - What it costs you: a package removed from the cache downloads again the next time an environment needs it.
- Does it come back? The cache refills as you install. Environments are different: one you remove is gone unless you exported it first.
- SiftMac’s verdict: Rebuilds
1. What pkgs and envs hold
conda downloads each package as an archive, unpacks it into its package cache, pkgs, and then links the files into every environment that uses it. When the cache and the environments are on the same disk, those are hard links: one file on disk with two names. A package shared by five environments takes its space once.
pkgs: downloaded archives (tarballs) and unpacked packages, including old versions left behind by updates, plus conda’s index cache.envs: one folder per named environment, each a full Python or R installation with its packages.
Updates and new environments keep adding to pkgs; conda clean is how it shrinks.
2. Where they are
Both sit inside conda’s base folder, which depends on how you installed it. Miniconda’s command-line installer proposes ~/miniconda3, its graphical installer uses /opt/miniconda3, and Miniforge and Anaconda use their own folders. Ask conda:
conda info --base
conda config --show pkgs_dirs envs_dirs
conda env list
3. How big they are, without counting twice
Because environments and pkgs share hard-linked files, measuring pkgs alone counts every package in full, including those no cleanup would remove. Measure the whole base folder for the real total, pkgs for an upper bound, and let conda tell you what a clean would free:
du -sh "$(conda info --base)"
du -sh "$(conda info --base)/pkgs"
conda clean --all --dry-run
The dry run lists exactly what conda clean --all would delete, so it’s the honest number.
4. How to clear it
- Close Jupyter, editors and terminals that are using a conda environment.
- Preview, then clean.
conda clean --allremoves the index cache, unused cached packages, tarballs, temporary files and log files. - Leave out
--force-pkgs-dirs(-f). It isn’t part of--all: it removes every writable package cache, and conda’s docs warn it breaks environments installed with symlinks back to that cache.
conda clean --all --dry-run
conda clean --all
conda only checks environments it knows about. Ones that conda info --envs doesn’t list aren’t checked for links back to the cache, so make sure yours show up before cleaning.
Old environments
Environments are yours: conda can’t rebuild one unless you saved what was in it. For each one you might want again, export it, then remove it:
conda env export --name old-env --from-history > old-env.yml
conda remove --name old-env --all
--from-history saves only the packages you asked for, which makes a file that works across platforms. To bring it back later, conda’s docs recommend conda create --file old-env.yml; the older conda env create --file old-env.yml still works. After removing environments, run conda clean --all again, since packages only they used are now unused.
5. What happens afterwards
- Environments you kept work as before: conda only removed packages none of them use.
- Installing a package or creating an environment that needs something you cleaned out downloads it again, so that install is slower and needs the network.
- A removed environment is gone. Its YAML file recreates it, with fresh downloads.
- Jupyter kernels or editor settings that pointed at a removed environment need pointing somewhere else.
Questions
Will conda clean --all break my environments?
No. It removes packages no environment uses, plus archives, caches and logs. The option that can break environments, --force-pkgs-dirs, isn’t included in --all.
Why did conda clean free less than the size of pkgs?
Most of pkgs is shared with your environments through hard links. Those files stay because environments still use them; only packages no environment links to are removed.
Can I just delete the pkgs folder in Finder?
Don’t. Environments installed with symlinks back to the cache stop working, and conda loses track of what it has. conda clean does the job safely.
What’s the difference between --packages and --tarballs?
--tarballs removes only the downloaded archives; --packages removes unpacked packages that no environment uses. --all includes both.
How SiftMac handles it. SiftMac leaves conda’s folders to conda: it doesn’t clear pkgs or remove environments, because only conda knows which packages its environments share. Its space map can show how big the conda folder and each environment in it are, so you can see which ones to export and remove.
Download SiftMac · scanning is free, and so is your first 2 GB of cleaning · See how it works