问题描述
我想更新我使用 cargo install
全局安装软件包的软件包,例如 rustfmt 或 Racer.我找不到更新已安装包的方法,而无需先将其删除(通过 cargo uninstall
),然后再次运行安装命令.有更新命令吗?
I'd like to update a package that I used cargo install
to globally install packages, such as rustfmt or racer. I can't find a way to update an installed package without first deleting it (via cargo uninstall
) and then running the install command again. Is there an update command?
推荐答案
从 Rust 1.41.0 开始,您可以使用以下命令将 crate 更新到最新版本:
As of Rust 1.41.0, you can use the following command to update crates to their latest version:
cargo install <crate>
这来自拉取请求 #6798(添加安装升级) 和在 #7560 (Stabilize install-upgrade) 中得到稳定.
This came from pull request #6798 (Add install-upgrade) and was stabilized in #7560 (Stabilize install-upgrade).
当 cargo install
检测到一个包已经安装时,它不会失败,如果版本不匹配,它会升级,或者如果它被认为是up-to",则什么都不做(退出 0)-日期".
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".
以下命令将总是卸载、下载和编译最新版本的 crate - 即使没有可用的更新版本.在正常情况下,应该首选 install-upgrade
功能,因为如果没有新版本的 crate,它确实可以节省时间和带宽.
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>
文档
更多信息可以在 GitHub 问题 rust-lang/cargo#6797 和 在官方文档章节.
这篇关于货物安装是否有等效的更新命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!