Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is cargo update updating the lock file

Tags:

rust-cargo

I don't manage to understand what cargo update do and I find the doc inconsistent.

https://doc.rust-lang.org/cargo/commands/cargo-update.html

Actually it says:

  • "name: Update dependencies as recorded in the local lock file" from which I guess that cargo.lock is just read from
  • "description: This command will update dependencies in the Cargo.lock file to the latest version. If the Cargo.lock file does not exist, it will be created with the latest available versions." from which I guess that it will write the Cargo.lock. but how, according to which rules, I'm not sure about
like image 511
ClementWalter Avatar asked Oct 24 '25 01:10

ClementWalter


1 Answers

The documentation needs to be updated. cargo update will update minor and patch versions of your dependencies inside Cargo.lock, i.e. update everything without introducing breaking changes as long as your dependencies adhere to Cargo's semver compatibility.

There is also cargo upgrade which will upgrade dependencies in Cargo.toml. It can be instructed to upgrade even major versions and then you might have to fix some breaking changes.

like image 113
Ordoshsen Avatar answered Oct 26 '25 22:10

Ordoshsen