Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear the Cargo cache?

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.

like image 841
bojangle Avatar asked Aug 01 '14 04:08

bojangle


People also ask

Can I delete cargo registry?

It is safe to delete . cargo/registry , yeah. It would be nice to have a command to do it for you though! It would be nice if there was a way to just clean out old crates that you're no longer using from the cache.

What does cargo lock do?

The purpose of a Cargo. lock is to describe the state of the world at the time of a successful build. It is then used to provide deterministic builds across whatever machine is building the package by ensuring that the exact same dependencies are being compiled.

Where does cargo build output go?

Cargo stores the output of a build into the "target" directory. By default, this is the directory named target in the root of your workspace. To change the location, you can set the CARGO_TARGET_DIR environment variable, the build. target-dir config value, or the --target-dir command-line flag.

What is cargo clean?

DESCRIPTION. Remove artifacts from the target directory that Cargo has generated in the past. With no options, cargo clean will delete the entire target directory.


2 Answers

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.

like image 73
huon Avatar answered Sep 23 '22 14:09

huon


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

$ cargo install cargo-cache $ cargo cache -a 
like image 32
Michael Mc Donnell Avatar answered Sep 21 '22 14:09

Michael Mc Donnell