y_tach
y_tach

Reputation: 61

How can I find the latest stable version of a crate using cargo?

I want to know the latest actix-web version, so I executed cargo search actix-web. The result is actix-web = "4.0.0-beta.1", showing the beta version number.

I want to know the latest stable version number; how do I get it?

Upvotes: 5

Views: 5573

Answers (2)

Shepmaster
Shepmaster

Reputation: 430673

Usually, I only care to know about the version number of a crate when I'm going to add the crate to my Cargo.toml. In those cases, I use two extra Cargo subcommands from the cargo-edit project:

  • cargo add — adds the current stable version of a crate to Cargo.toml. Options exist for allowing prerelease versions or marking it as a build / dev dependency.
  • cargo upgrade — updates the version of a crate already in Cargo.toml. Similar to cargo update, but also changes Cargo.toml in addition to Cargo.lock.

Upvotes: 4

y_tach
y_tach

Reputation: 61

cargo show --json $1 | python -m json.tool | jq ".versions[].num"

Upvotes: 0

Related Questions