How to update dependencies to the latest

Hi.

I'm trying to update dependencies of my project to the latest.
but cargo update won't update, for example, rayon to the 1.10.0.(the latest at this time)

In cargo.toml, rayon was set to 1.8.0.

How could I update all dependencies to the latest?

cargo update will update the dependencies in the Cargo.lock file, meaning your project will be built with the update dependency. See also Cargo.toml vs Cargo.lock - The Cargo Book

What is specified in the Cargo.toml instead is just a version requirement (see Specifying Dependencies - The Cargo Book). In your case your crate is declaring it needs rayon at least version 1.8.0, but it's compatible with any other later 1.x version.

4 Likes

Also, if you want to upgrade the dependency versions in Cargo.toml, you can use cargo-edit.

I run this command every so often in my projects to update all dependencies:

# cargo upgrade is provided by `cargo-edit`
cargo upgrade -i allow && cargo update
3 Likes

If then do I need to modify cargo.toml manually?

If you want to require at least rayon 1.10 when building your program/library then you'll have to either manualy modify the Cargo.toml or use cargo upgrade from the cargo-edit third party command as @azriel91 just showed.

If instead you're fine with just building your program/library using rayon 1.10 then cargo update is enough.

Thanks