Does cargo install have an equivalent update command?

半城伤御伤魂 提交于 2019-11-28 21:00:56
Nicolai Fröhlich

As of Cargo 1.36.0, you can now use the following command(s) on a nightly toolchain instead of using the cargo-update crate to update crates to their latest version:

rustup install nightly
cargo +nightly install -Z install-upgrade <crate>

This came from pull request #6798 (Add install-upgrade).

How does it work?

Instead of failing when cargo install detects a package is already installed, it will upgrade if the versions don't match, or do nothing (exit 0) if it is considered "up-to-date".

Forcing an Upgrade / Re-Installation

The following command will always uninstall, download and compile the latest version of the crate - even if there's no newer version available. Under normal circumstances the install-upgrade feature should be preferred as it does save time and bandwidth if there's no new version of the crate.

cargo install --force <crate>

Documentation

Further information can be found in the GitHub issue rust-lang/cargo#6797 and in the official documentation chapter Unstable Features -> install-upgrade.

There is no such command in vanilla cargo (well, there's cargo install but that's for dependencies), but since cargo supports third-party subcommands there is an answer: the cargo-update crate.

Install as usual with cargo install cargo-update, then use cargo install-update -a to update all installed packages, for more usage information and examples see the cargo install-update manpage.

Disclaimer: am author

A solution I've found is to add the --force flag to the install command. For example cargo install --force clippy. This will effectively re-install the latest version.

Nope. You can discuss it in this issue.

The command to update dependencies is cargo update

Source : http://doc.crates.io/guide.html

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!