You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To learn more about the subdirectories inside the cargo home and what can be safely deleted, check --info.
Usage:
Removes items older than specified date: YYYY.MM.DD or HH:MM:SS
-r, --remove-dir Remove directories, accepted values: all,git-db,git-repos,
registry-sources,registry-crate-cache,registry-index,registr y
-t, --top-cache-items List the top N items taking most space in the cache
-V, --version Print version information
-y, --remove-if-younger-than Removes items younger than the specified date: YYYY.MM.DD or HH:MM:SS
SUBCOMMANDS:
clean-unref remove crates that are not referenced in a Cargo.toml from the cache
help Print this message or the help of the given subcommand(s)
l check local build cache (target) of a rust project
local check local build cache (target) of a rust project
q run a query
query run a query
r query each package registry separately
registry query each package registry separately
sc gather stats on a local sccache cache
sccache gather stats on a local sccache cache
toolchain print stats on installed toolchains
trim trim old items from the cache until maximum cache size limit is reached
verify verify crate sources">USAGE: cargo cache [OPTIONS] [SUBCOMMAND]
OPTIONS: -a, --autoclean Removes crate source checkouts and git repo checkouts -e, --autoclean-expensive As --autoclean, but also recompresses git repositories -f, --fsck Fsck git repositories -g, --gc Recompress git repositories (may take some time) -h, --help Print help information -i, --info Print information cache directories, what they are for and what can be safely deleted -k, --keep-duplicate-crates Remove all but N versions of crate in the source archives directory -l, --list-dirs List all found directory paths -n, --dry-run Don't remove anything, just pretend -o, --remove-if-older-than Removes items older than specified date: YYYY.MM.DD or HH:MM:SS -r, --remove-dir Remove directories, accepted values: all,git-db,git-repos, registry-sources,registry-crate-cache,registry-index,registry -t, --top-cache-items List the top N items taking most space in the cache -V, --version Print version information -y, --remove-if-younger-than Removes items younger than the specified date: YYYY.MM.DD or HH:MM:SS
SUBCOMMANDS: clean-unref remove crates that are not referenced in a Cargo.toml from the cache help Print this message or the help of the given subcommand(s) l check local build cache (target) of a rust project local check local build cache (target) of a rust project q run a query query run a query r query each package registry separately registry query each package registry separately sc gather stats on a local sccache cache sccache gather stats on a local sccache cache toolchain print stats on installed toolchains trim trim old items from the cache until maximum cache size limit is reached verify verify crate sources
This removes extracted tarball sources and repository checkouts.
The original source archives and git repos are kept and will be extracted as needed by cargo.
Run cargo cache --autoclean:
The crate also works if you override the default location of the cargo home via
the $CARGO_HOME env var!
Side note: cargo-cache started as my learning-by-doing rust project, if you see something that you find very odd or is in dire need of improvement please let me know and open a ticket!
Cleaning the cache on CI
Sometimes it is desired to cache the $CARGO_HOME in CI.
As noted in the document, this might cache sources twice which adds unnecessary overhead.
To reduce the size of the cache before storing it, you might want to run cargo cache --autoclean.
The ci-autoclean feature provides a very stripped-down version of the crate that is only capable of running cargo-cache --autoclean automatically on launch and should compile within a couple of seconds.
To make use of this, you can add these commands to your ci:
cargo install (--git git://github.com/matthiaskrgr/cargo-cache OR cargo-cache) --no-default-features --features ci-autoclean cargo-cache cargo-cache # no further arguments required
You can add the vendored-libgit feature if you would like to link libgit statically into cargo-cache.
FAQ
Q: Is this project related to sccache?
A: Not really.
cargo cache sccache prints a little summary of the local(!) sccache-cache and shows how many files were last accessed on a given date but
it does not modify sccaches cache. It also does not act as a compiler cache such as (s)ccache.
License:
Copyright 2017-2022 Matthias Kruger
Licensed under the Apache License, Version 2.0 http://www.apache.org/licenses/LICENSE-2.0> or the MIT license , at your option. All files in the project carrying such notice may not be copied, modified, or distributed except according to those terms.
About
manage cargo cache (${CARGO_HOME}, ~/.cargo/), print sizes of dirs and remove dirs selectively