Is there a command to update Cargo to the latest official release?

Filip Allberg picture Filip Allberg · Jun 20, 2016 · Viewed 18.5k times · Source

I seem to have diverging versions of rustc and cargo (I think),

$ rustc -V
rustc 1.9.0 (e4e8b6668 2016-05-18)
$ cargo -V
cargo 0.10.0-nightly (10ddd7d 2016-04-08)

Is there a command akin to

pip install --upgrade pip 

for upgrading cargo? I.e. something like

cargo install --upgrade cargo

Answer

Shepmaster picture Shepmaster · Jun 20, 2016

You should update rustc and cargo based on how you installed it. If you used rustup, a rustup update should suffice. If you used a package manager or a binary installer, check those sources for an update.

rustc and cargo are shipped together, but that doesn't mean that their versions need to match. In fact, they do not match until Rust 1.26.0, when the Cargo binary was changed to print the Rust version.

I have the same versions of rustc and cargo that you do; those are the ones that correspond to the Rust 1.9 release. There's nothing to worry about.


If you really want to, you can download a nightly version of Cargo or compile your own. As long as your version exists in your PATH before the older one, it will be used.

I used to do this with my local Rust builds in order to have a version of Cargo at all, although rustup now automatically uses the cargo from the most recent stable version when there isn't one available in the current toolchain, which is nice.