我似乎有不同版本的rustc
和cargo
(我想)。
$ rustc -V
rustc 1.9.0 (e4e8b6668 2016-05-18)
$ cargo -V
cargo 0.10.0-nightly (10ddd7d 2016-04-08)
是否有类似于
的命令?Is there a command akin to
pip install --upgrade pip
升级 cargo
的方法?例如:
cargo install --upgrade cargo
我似乎有不同版本的rustc
和cargo
(我想)。
$ rustc -V
rustc 1.9.0 (e4e8b6668 2016-05-18)
$ cargo -V
cargo 0.10.0-nightly (10ddd7d 2016-04-08)
是否有类似于
的命令?pip install --upgrade pip
升级 cargo
的方法?例如:
cargo install --upgrade cargo
rustup update
命令足以更新rustc
和cargo
。如果你使用的是包管理器或二进制安装程序,请查找这些来源以获取更新。rustc
和cargo
一起发布,但这并不意味着它们的版本需要匹配。事实上,在Rust 1.26.0之前,它们并不匹配,直到更改了Cargo二进制文件以打印Rust版本为止。rustc
和cargo
,它们对应于Rust 1.9版本发布。没有什么可担心的。
PATH
中,它将被使用。cargo
(当当前工具链中没有可用版本时),这很不错。简短版:运行命令 rustup update
可以同时更新 Rust 和 Cargo:
$ rustc --version
rustc 1.27.2 (58cc626de 2018-07-18)
$ cargo --version
cargo 1.27.0 (1e95190e5 2018-05-27)
$ rustup update stable
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2018-08-02, rust version 1.28.0 (9634041f0 2018-07-30)
info: downloading component 'rustc'
info: downloading component 'rust-std'
info: downloading component 'cargo'
info: downloading component 'rust-docs'
info: removing component 'rustc'
info: removing component 'rust-std'
info: removing component 'cargo'
info: removing component 'rust-docs'
info: installing component 'rustc'
info: installing component 'rust-std'
info: installing component 'cargo'
info: installing component 'rust-docs'
$ rustc --version
rustc 1.28.0 (9634041f0 2018-07-30)
$ cargo --version
cargo 1.28.0 (96a2c7d16 2018-07-13)
你还需要更改默认设置:
> rustc --version
rustc 1.41.0 (5e1a79984 2020-01-27)
> rustup update stable
> rustc --version
rustc 1.41.0 (5e1a79984 2020-01-27)
> rustup default stable-x86_64-apple-darwin
> rustc --version
rustc 1.47.0 (18bf6b4f0 2020-10-07)
使用 cargo 更新自身:
cargo install cargo --force
这将重新编译该软件包并安装最新版本。
我决定发布此内容,是因为我发现rustup没有将cargo更新到1.57。
您可以使用rustup cli编辑您正在使用的cargo和rust版本。您可以指定特定版本或指定通道,如夜间版或测试版。
例如:
rustup override set nightly
multirust update
. 或者看看 Rustup,但我还没有使用过它。 - starbluemultirust
已经被废弃,请使用 https://github.com/rust-lang-nursery/rustup.rs。 - Isan Rivkin