Update Rust packages
Rust のパッケージは Cargo.toml で管理されていますが,npm のように install
コマンドで全てのパッケージが簡単に更新できるような感じではないようです.
Update packages individually
Update to the latest version
terminal
$ cargo update -p PACKAGE
It seems that it is also available for install
command.
$ cargo install -f PACKAGE
Update to the specific version
terminal
$ cargo update -p PACKAGE --precise x.x.x
Update packages in bulk
There is a tool called cargo-update
that updates packages in bulk.
terminal
$ cargo install cargo-update
$ cargo install-update -a
When executed, all packages are updated to the latest version possible without breaking dependencies.
Error
The following error may occur when using the install
command.
This command manages Cargo's local set of installed binary crates. Only packages which have executable [[bin]] or [[example]] targets can be installed, and all executables are installed into the installation root's bin folder.
Reference: cargo install - The Cargo Book
If the package does not have an executable file, the install
command does not seem to work. In this case, you need to edit the Cargo.toml file.
You can check the version of the package you want to install and its dependencies at crates.io. After editing the Cargo.toml, a cargo build
will fetch the package and update the Cargo.lock.