«Cargo install» exists, but «cargo update» doesn't? A familiar pain for every Rust developer
\n\nYou just ran cargo install ripgrep to get the fresh rg binary. A week passes. You hear a new version is out — 14.1.0 instead of 13.0.0. And then a reasonable question arises: «Does cargo install have an equivalent update command?»
This question has gathered thousands of views on Stack Overflow. And for good reason. The fact is that cargo has no built-in cargo install update command. No, you're not going blind. It really doesn't exist. But that doesn't mean you're doomed to manually download new versions. There are several approaches, and we'll cover them all — from simple to elegant.
In this article, we won't just translate the Stack Overflow answer. We will compare approaches, show real code, and give actionable advice. Let's go!
\n\nWhy is there no «update» command in Cargo for installed crates?
\n\nBefore rushing to look for bugs, let's understand the philosophy. cargo install is designed for installing binary crates (those that have a [[bin]] section in their Cargo.toml). It is not a package manager like apt or npm. Cargo is first and foremost a build system and dependency manager for projects, not a global software installer.
The cargo update command exists, but it works inside a project — it updates dependencies in Cargo.lock. For globally installed binaries, a different solution is needed.
Method #1: Classic reinstallation (cargo install --force)
\n\nThe simplest and most obvious method is to reinstall the crate with the --force flag:
# Installed the first time\ncargo install ripgrep\n\n# A week later — update\ncargo install --force ripgrep\n\n\nWhat happens under the hood? Cargo downloads the latest version of the crate from crates.io, rebuilds it, and replaces the binary. The --force flag forces overwriting the existing file, even if the version is the same.
Pros:
\n- \n
- Does not require installing additional tools \n
- Works always and everywhere \n
- Intuitively clear \n
Cons:
\n- \n
- Full recompilation every time (slow if the crate is large) \n
- No check if a new version is available — you just reinstall \n
- Inconvenient if you have 10+ crates installed \n
It's like reinstalling Windows to update a driver. Does it work? Yes. Is it optimal? No.
\n\nMethod #2: cargo-outdated — a smart detector for outdated crates
\n\nIf you want to know for sure that an update is needed, install cargo-outdated:
cargo install cargo-outdated\n\n\nNow check which crates are outdated:
\n\ncargo outdated --root ~/.cargo\n\n\nThe output will show something like:
\n\nPackage Current Latest Deps\nripgrep 13.0.0 14.1.0 -\nbat 0.22.1 0.23.0 -\n\n\nThen you can update a specific crate using cargo install --force. But this is still two steps. Want automation? Read on.
Pros:
\n- \n
- Shows only those crates that are actually outdated \n
- Works for project dependencies as well \n
- Has filtering options \n
Cons:
\n- \n
- Does not update itself — only informs \n
- Requires separate installation \n
Method #3: cargo-update (yes, such a crate exists!)
\n\nThe most elegant answer to the question «Does cargo install have an equivalent update command?» is