Pablo Tato Ramos
Pablo Tato Ramos

Reputation: 429

Why is the ~/.cargo directory so big?

On my Windows 10 machine it's 3.5GB. What is it storing? How can I trim it down?

Upvotes: 12

Views: 10469

Answers (2)

Chayim Friedman
Chayim Friedman

Reputation: 71595

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.

Upvotes: 1

Acorn
Acorn

Reputation: 26194

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.

Upvotes: 16

Related Questions