On my Windows 10 machine it's 3.5GB. What is it storing? How can I trim it down?
It is storing all the downloaded crates you have used, their binaries, the index of registries, etc. It is going to take a lot of space and will keep increasing.
You can safely remove .cargo/registry/
(if you remove the entire folder, you will lose installed binaries and your Cargo configuration if you had one). Afterwards, everything you use again will be downloaded and it will start growing back. It is a common way of getting rid of very old dependencies you are not using anymore.
~/.cargo/registry/
(assuming Windows has the same folder hierarchy as Linux). The rest are the binaries you've installed (you probably don't want to remove those) and the configuration (that's tiny). The registry is the one big thing, it can safely be removed, and will be reconstructed as needed. –
Erumpent ~/.cargo
. This would actually save some space if you have multiple projects which use the same dependencies. –
Vermont .cargo/registry
has 3 subdirectories, I'd there's probably no need to remove index
(which would be the cargo index) and cache
is just the crate data so may or may not be useful to clean up. –
Ludovico You can now keep the directory smaller on nightly, if you set in .cargo/config.toml
(for example, ~/.cargo/config.toml
or %USERPROFILE%\.cargo\config.toml
:
[unstable]
gc = true
Then, Cargo commands will check once a day for crates that weren't used for a long time, and delete them from the cache.
For more information and additional configuration, see the blog post introducing the feature and the feature's section in the Cargo book.
© 2022 - 2024 — McMap. All rights reserved.
.cargo
does not include build artifacts for a given project. – Jebel