cargo install presently offers two behaviors:
cargo install: will install a bin crate if it isn't installed already. If it is, it errors out saying a binary is already installed, suggesting "Add --force to overwrite"
cargo install --force: will always overwrite existing binaries, even if they came from the same version of the same bin crate
This is problematic in CI environments where people would like to
cargo install a utility to run as part of their CI pipeline, and leverage the CI environment's built-in caching functionality so subsequent runs can use the previously built binary. It seems in cases like this one of two things happens:
- They don't reinstall if the binary is already installed, leaving them stuck on the first version they install. This is fast but leaves them stale.
- They add
--force, always reinstalling for every run, which is both slow and runs up the crates.io bandwidth usage.
I think it'd be great if there were a middle option, which would act like
--force, but idempotent for binaries which are installed from the same version of the same crate. That is to say: if you're reinstalling the same binaries from the same crate it's a noop, but if there's a new version of that crate it installs that and overwrites the previous version.
cargo install --update cargo-audit
cargo-audit issue: https://github.com/RustSec/cargo-audit/issues/143