Cargo-cache: tame your ${CARGO_HOME}

In case you have been wondering how much data cargo has already been downloading when it fetches crates or git repositories, cargo-cache gives some insight.

When cargo downloads packages, by default they land in ~/.cargo/ (or ${CARGO_HOME} if manually overridden).
cargo-cache is a simple cli-tool that allows you to inspect the download cache and can do different levels of cleanups.

Installation: cargo install cargo-cache

By default (cmd: cargo cache), it leaves the cache untouched and only displays some statistics:

Cargo cache '/home/matthias/.cargo':

Total size:                             7.22 GB
Size of 101 installed binaries:           909.51 MB
Size of registry:                         1.46 GB
Size of registry index:                     63.65 MB
Size of 3082 crate archives:                435.72 MB
Size of 2038 crate source checkouts:        963.10 MB
Size of git db:                           4.84 GB
Size of 107 bare git repos:                 980.81 MB
Size of 100 git repo checkouts:             3.86 GB

You can clean out git checkouts and extracted .crate sources using the --autoclean arg.
This will keep the original sources and won’t require redownload in case cargo needs them again (the cloned bare repos and .crate archives are kept).
Check out --dry-run (cargo cache --autoclean --dry-run) if you want to know what would be removed beforehand.

cargo cache --info returns an explanation of what the different subdirectories of the cache are for.

cargo cache --top-cache-items 10 will tell about the 10 largest items of each part of the cache.

query lets you search for items that match this regex inside the cache.
This does only search filenames and not the actual content of the file though:
cargo cache query "rustc.*seria" --sort-by size -h

Registry cache sorted by size:
	rustc-ap-serialize-373.0.0: 34.69 KB
	rustc-ap-serialize-407.0.0: 34.70 KB
	rustc-ap-serialize-491.0.0: 34.84 KB
	rustc-ap-serialize-486.0.0: 34.84 KB
	rustc-ap-serialize-306.0.0: 35.11 KB
	rustc-serialize-0.3.24: 45.93 KB

Registry source cache sorted by size:
	rustc-ap-serialize-407.0.0: 193.97 KB
	rustc-serialize-0.3.24: 243.77 KB

check --help and the README for more details.

Upcoming changes (not included in 0.2.1):
Changes to default cache summary:

I tried to condense the default statistics a bit:


Total size:                             3.36 GB
Size of 103 installed binaries:           941.39 MB
Size of registry:                         1.29 GB
Size of registry index:                     226.02 MB
Size of 4570 crate archives:                716.23 MB
Size of 652 crate source checkouts:         348.68 MB
Size of git db:                           1.12 GB
Size of 118 bare git repos:                 1.08 GB
Size of 5 git repo checkouts:               37.97 MB


Total:                                3.36 GB
  103 installed binaries:           941.39 MB
  Registry:                           1.29 GB
    3 registry indices:             226.02 MB
    4570 crate archives:            716.23 MB
    652 crate source checkouts:     348.68 MB
  Git db:                             1.12 GB
    118 bare git repos:               1.08 GB
    5 git repo checkouts:            37.97 MB

and am curious to know what people think of it.

I also started implementing support for alternative registries.

(the new format now shows 3 registry indices: 226.02 MB)
and would appreciate feedback of people who used this feature and can tell me whether
they find if it triggers any misbehavior in cargo-cache (especially any windows since I don’t have a windows machine to try it on).

You can install the current git state of the project via cargo install --git

If you have any questions, feedback, bugreports or feature requests please let me know here or on

Have fun and happy hacking! :slight_smile: