Repository navigation
Releases
Releases · leostera/cargo-gc
v0.2
cargo gc run,testandbenchcollect only directories Cargo builds into. A program
they start writes to the same stderr as Cargo's log, so a line it printed in that log's
format made cargo-gc collect whatever directory it named, without any lock
(#1, reported by @cantoramann).- cargo-gc is published on crates.io.
v0.1
The first version.
cargo gc <command>runs any Cargo command with its output, colors, progress bar and exit
code unchanged, then collects its build directory generationally: what no build in the
last--keepgenerations (default 8) used is removed.--max-sizealso removes the
oldest generations while a profile directory is over a size.--unusedremoves what no
command run through cargo gc has used, to reclaim space in a build directory that grew
before it.cargo gcalone collects without building.- Cargo config files can set
--keepand--max-sizeasgc.keepandgc.max-size: a
project's.cargo/config.toml, or~/.cargo/config.tomlfor every project, found as Cargo
finds them.CARGO_GC_KEEPandCARGO_GC_MAX_SIZEoverride them, and flags override both. - Units built from package versions no
Cargo.locklists any more, or by a toolchain no build
uses any more, are removed after the first run that moved on, with everything built on them
and their incremental caches, whatever--keepsays: a dependency bump no longer leaves
its old builds behind for--keepgenerations. - Object files that later rustc invocations superseded are removed from the units that stay:
on macOS, debug builds keep every compile's object files, so editing and rebuilding grew a
build directory without bound. - Removal only ever costs a rebuild: only recognized units, incremental caches and superseded
object files go, only while cargo-gc holds Cargo's locks on the profile directory, one
rename per unit, fingerprint first. - Both build directory layouts:
build/<package>/<hash>/(Cargo 1.100 and newer) and
.fingerprint/,deps/,build/<package>-<hash>/(older Cargo). - macOS, Linux and Windows, with Cargo 1.89 and newer: CI runs the integration tests against
Cargo 1.89 too. - If Cargo builds units its log does not name, as a Cargo release that changed its log would,
cargo-gc warns and removes nothing. A build that compiles nothing is not warned about. - A GitHub Action,
leostera/cargo-gc@main, that installs cargo-gc (building it once per
runner OS, then from its cache), and can cache the build directory between runs while
cargo gc keeps it collected.