{"id":16722084,"url":"https://github.com/suvayu/moult","last_synced_at":"2026-05-10T00:44:09.534Z","repository":{"id":138513448,"uuid":"286143129","full_name":"suvayu/moult","owner":"suvayu","description":"Cleanup after conda","archived":false,"fork":false,"pushed_at":"2020-09-22T18:44:57.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-14T19:58:41.704Z","etag":null,"topics":["bash","conda","python","script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/suvayu.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-09T00:55:08.000Z","updated_at":"2021-05-21T15:37:03.000Z","dependencies_parsed_at":"2023-05-27T22:00:43.479Z","dependency_job_id":null,"html_url":"https://github.com/suvayu/moult","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"597c4a36be6c66fb53eea7289bcd9004fa8ac68c"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suvayu%2Fmoult","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suvayu%2Fmoult/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suvayu%2Fmoult/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/suvayu%2Fmoult/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/suvayu","download_url":"https://codeload.github.com/suvayu/moult/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243733330,"owners_count":20339024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bash","conda","python","script"],"created_at":"2024-10-12T22:33:26.427Z","updated_at":"2026-05-10T00:44:09.500Z","avatar_url":"https://github.com/suvayu.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":".. image:: https://live.staticflickr.com/1278/979979379_935bdb7037_n_d.jpg\n\nMoult\n=====\n\n``conda`` is a common way to manage Python environments.\nUnfortunately it's pretty terrible at being space efficient.  One\nissue being, it does not clean-up old packages.  As a user updates\ntheir environment, new versions of packages are downloaded and made\navailable in their environment.  However, the old package versions are\nnot removed, as another environment could be using it.  This means\nwith time a conda install gets filled up with these orphaned packages;\nalmost like *conda is moulting* :wink:.\n\nThis script uses the following logic to identify orphaned packages,\nand removes them.\n\n- List all packages used by all environments managed by ``conda``.  As\n  input it expects the conda install directory. ::\n\n    $ tree -L 1 /opt/conda/\n    /opt/conda/\n    ├── envs\n    └── pkgs\n\n  For the above install, it expects ``/opt/conda`` as argument.\n  Typically the install directory is in your ``$HOME``, something like\n  ``~/.conda``.\n\n- The script then creates a globbing pattern for each package that\n  matches the package versions that are not in use by an environment.\n\n  Say if ``env1`` uses ``pkg-1.0``, and ``env2`` uses ``pkg-1.2``, but\n  the package versions present are ``pkg-0.9.``, ``pkg-1.0``, and\n  ``pkg-1.2``, then ``pkg-0.9`` will be removed, and ``pkg-1.0`` and\n  ``pkg-1.2`` will be retained.\n\n- It also creates a pattern that matches all packages, where none of\n  the versions of a package are included in an environment.\n\n  Say ``env1`` used to include ``another-pkg-1.1``, but it was\n  removed, and no other environment includes it, then it will be\n  removed.\n\n- These patterns are then used to delete the orphaned packages (*like\n  dead skin from a real :snake:*).\n\n\nUsing the script\n----------------\n\nBy default the script runs in dry run mode, it will only try to list\nthe packages that would be deleted.  Since the globbing pattern is\nformed as a negative match, you will see errors if there are no\norphaned versions for a particular package.  For the rest, the\norphaned versions are listed.  This way you can confirm what would be\ndeleted if you were to run the script.\n\nTo delete the orphaned packages, you need to pass the ``--run``\noption, except this time instead of listing the orphaned versions of\nthe packages, it deletes them recursively.  The delete command is\nhardcoded to be verbose (``rm -r -v`` ) so that you know exactly what\nwas done in case something goes wrong.  Again, since the pattern is a\nnegative match, if there are no orphaned version for a package, it\nwill generate an error from the ``rm`` command, which can be safely\nignored.  I have chosen to not silence these messages as they give\nvisibility to what is going on, and is useful to debug in case\nsomething goes wrong.\n\nIt is advised to log both *stderr* and *stdout* to a log file. ::\n\n  $ moult /opt/conda --run |\u0026 tee dead-skin.log\n\n\n*The social media preview is thanks to Scott Ableman and can be found\non* Flickr_.\n\n.. _Flickr: https://www.flickr.com/photos/ableman/979979379\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuvayu%2Fmoult","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsuvayu%2Fmoult","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsuvayu%2Fmoult/lists"}