What is ~/.cargo/registry on Mac? Is it safe to delete?
Yes, ~/.cargo/registry is safe to delete. It holds the registry index and downloaded crates, and Cargo fetches whatever a project needs the next time you build.
Where it is
~/.cargo/registryWhat it is
Cargo, the Rust package manager, keeps three things in ~/.cargo/registry: the index of available crates, a cache folder with the compressed .crate files it downloaded, and a src folder with those crates unpacked for the compiler.
It grows as your projects use more crates and more versions of them. The unpacked sources in src usually take more space than the compressed downloads.
Compiled output is not stored here. That lives in each project's target folder, which is often much larger.
How big it gets
Typically hundreds of MB to a few GB.
How to clear it by hand
- Make sure no cargo build is running.
- Run the command below. It deletes the downloaded crates and their unpacked sources, and leaves the registry index in place.
- Do not delete ~/.cargo/bin, which holds cargo itself and the tools you installed with cargo install.
rm -rf ~/.cargo/registry/cache ~/.cargo/registry/srcWhat happens afterwards
The next cargo build downloads and unpacks the crates the project needs, so it takes longer and needs a network connection. Your code and installed Rust toolchains are unaffected.
How Diskzy handles it
Diskzy lists the Cargo cache in the Clean up tab and ticks it.
Related guides
See where your Mac's space went
Diskzy maps your disk, explains System Data and clears what's safe. Free for 72 hours, then $9 once for 2 Macs.
Try Diskzy for free