//配置https://static.rust-lang.org/rustup和https://static.rust-lang.org的镜像
//字节跳动镜像
echo 'export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"' >> ~/.bashrc
echo 'export RUSTUP_DIST_SERVER="https://rsproxy.cn"' >> ~/.bashrc
//中国科学技术大学镜像
echo 'export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"' >> ~/.bashrc
echo 'export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static"' >> ~/.bashrc
//重启终端生效或执行以下命令立即生效
source ~/.bashrc
//安装
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
//重启终端生效或执行以下命令立即生效
source ~/.bashrc
//查看版本
rustup --version
rustc --version
cargo --version
//新建文件
touch ~/.cargo/config.toml
//配置https://crates.io的镜像
//字节跳动镜像
cat << EOF | tee -a ~/.cargo/config.toml
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy-sparse]
index = "sparse+https://rsproxy.cn/index/"
EOF
//中国科学技术大学镜像
cat << EOF | tee -a ~/.cargo/config.toml
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
[registries.ustc]
index = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
EOF
原创文章,作者:huoxiaoqiang,如若转载,请注明出处:https://www.huoxiaoqiang.com/rust/rustenv/38503.html