Rust国内源

1、安装rust

通过官方源一般较慢curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

curl -sSf  https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh | sh

如果安装慢可以考虑替换地址:

curl -sSf  https://sh.rustup.rs > rustup-init.sh
# 或者
curl -sSf  https://cdn.jsdelivr.net/gh/rust-lang-nursery/rustup.rs/rustup-init.sh > rustup-init.sh

会生成一个 rustup-init.sh 文件,打开当前文件:
会看到变量:

RUSTUP_UPDATE_ROOT="https://static.rust-lang.org/rustup/dist"

将这个变量后边的地址进行替换,这个地址为中国科学技术大学官网:

RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup/dist"

然后通过bash rustup-init.sh来安装rust

2、安装稳定版本或者nightly版本

$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install stable # for stable
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install stable # for stable
$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly # for nightly
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly # for nightly
$ # for bash
$ RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly-YYYY-mm-dd
$ # for fish
$ env RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup rustup install nightly-YYYY-mm-dd

3、Cargo配置:

#(base) ➜  ~ cat ~/.cargo/config
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

参考:
Rust Toolchain 反向代理使用帮助
Rustup 镜像安装帮助

你可能感兴趣的:(Rust国内源)