头图

Rust 版本升级 rustup update stable 报错

一、报错内容

error: could not download file from 'https://static.rust-lang.org/dist/channel-rust-stable.toml.sh...): error trying to connect: tcp connect error: Connection refused (os error 61): error trying to connect: tcp connect error: Connection refused (os error 61): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)

error: could not download file from '<https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256>' to '/Users/xxx/.rustup/tmp/rv6vdfu3eupwo64m\_file': failed to make network request: error sending request for url (<https://static.rust-lang.org/dist/channel-rust-stable.toml.sha256>): error trying to connect: tcp connect error: Connection refused (os error 61): error trying to connect: tcp connect error: Connection refused (os error 61): tcp connect error: Connection refused (os error 61): Connection refused (os error 61)

错误内容:
系统无法连接到 Rust 语言官方的静态文件服务器 static.rust-lang.org,导致对应的文件没有下载到指定的文件夹中

二、解决方案-手动安装对应文件(推荐)

1. 下载对应的文件

点击下面链接进行下载
https://static.rust-lang.org/dist/channel-rust-stable.toml.sh...

2. 放到指定文件夹中

在报错内容中可以看到是放到你的 /Users/xxx/.rustup/tmp/ 这个文件夹中,打开文件夹,放到对应内容中即可,如下所示:

rustup

3. 重新执行 rustup update stable

终端中重新执行 rustup update stable 即可进行 rust 更新

升级版本下载比较多的内容,耐心等待即可

4. 查看新版本

4.1. cargo version

cargo 更新
cargo 更新

4.2. rustup --version

rustup 更新
rustup

4.3. rustc --version

rust 更新
rust

三、解决方案-重新安装 Rustup

1. 先卸载 rustup

rustup self uninstall

2. 重新安装

curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

月恒
40 声望4 粉丝

前端