How to clear the Cargo cache?

28,464

Solution 1

I believe that manifest file is just for the built-in libraries, i.e. those distributed with rustc. cargo itself stores things in ~/.cargo (for the moment), if you do wish to just remove all the libraries then deleting that directory won't break anything.

If you're just wanting cargo to rebuild/update dependencies you can run cargo update.

Solution 2

Install and run cargo-cache to clear the cache in the ~/.cargo folder:

$ cargo install cargo-cache
$ cargo cache -a
Share:
28,464

Related videos on Youtube

bojangle
Author by

bojangle

Janitor by day, batmancoder by night.

Updated on August 20, 2021

Comments

  • bojangle
    bojangle over 2 years

    When I run cargo build, various libs get stored within the folder /usr/local/lib/rustlib/.

    What is the correct way to clear these libs? I could rm these files manually, but would that be the right thing to do? I noticed that /usr/local/lib/rustlib/manifest is a file containing a list of the fill file paths of all the libs, and hence might be breaking something if I remove these files manually.

  • bojangle
    bojangle almost 10 years
    Thanks for pointing me to ~/.cargo, that is what I was looking for!
  • DenisKolodin
    DenisKolodin over 3 years
    keep the bin folder if you don't want to reinstall all that cool Rust tools you've installed )
  • Mathieu CAROFF
    Mathieu CAROFF over 2 years
    error caused by "feature resolver is required" :sad_face:
  • chovy
    chovy about 2 years
    error: no such subcommand: cache
  • Michael Mc Donnell
    Michael Mc Donnell about 2 years
    @chovy did you remember to install cargo-cache first?
  • Matthew Strawbridge
    Matthew Strawbridge about 2 years
    In particular, by default this will remove the cargo executable itself too.