Search code examples
pythonpandasanacondacondaminiconda

Will "conda clean" erase my favorite packages?


I have to do some cleanup with my (Mini)conda python packages to free some disk space, and I see people usually resort to the conda clean command to get this job done. Conda documentation says that it it's safe to do that, as it will only erase packages that "have never been used in any environment".

I've never used conda's environments feature, though, and I don't know if I should be doing so. I just install my packages with conda install commands, run Jupyter Notebook and do all my work inside Jupyter. (I'm not a software engineer, just a regular dude using python and pandas to manage data.)

Do I risk erase my favorite packages if i run conda clean? If I don't do any cleanup, will conda eventually engulf all of my disk space? Is there any command I can use to check how much disk space my python packages are taking.


Solution

  • At the very least, tarballs can be removed with no risk. Cleaning packages is done based on counting the number of hardlinks for the package. If there is only one hardlink, this implies the package is not referenced by any environment, and therefore can be removed. This will be the case for all packages that were previously in use but were superseded by other versions.

    The warning mainly applies to people who have environments across different disks but are using softlinks to limit redundancy. Unlike hardlinks, the file system does not keep track of softlink references, so there is no simple way to count the number of softlinks. Hence, when cleaning, those packages that are only connected to envs through softlinks (i.e., only report one hardlink) will be removed and thereby break the softlinking envs.