Benjamin Sago / ogham / cairnrefinery / etc…

Technical notes Clear out old Rust artefacts with cargo-sweep

A couple of my projects require the Rust “nightly” compiler, and while features are regularly being stabilised, there are still a couple that I need that have not yet made the jump.

As its name suggests, the nightly compiler is updated a lot more often than the stable and beta versions, so nightly build results can and will go out-of-date very quickly. I have a lot of Rust projects, and I don’t want outdated build artefacts to hang around any longer than they need.

The cargo-sweep subcommand is perfect for dealing with this.

To invoke it, I have a script, sweep-rust, that I run after running rustup update. I pass it the -i flag to remove build artefacts not made by any of the currently-installed compilers, and the -r flag to recurse into sub-directories.
#!/bin/bash -e
exec parallel cargo sweep -i -r ::: \
    ~/Projects/dog/dog-code \
    ~/Projects/exa/exa-code \

No comments about my folder structure, please!