180 条记录
15 私有链接
15 私有链接
Windows
rustup set profile minimal
中国科技大学:
setx RUSTUP_DIST_SERVER "https://mirrors.ustc.edu.cn/rust-static" /M
setx RUSTUP_UPDATE_ROOT "https://mirrors.ustc.edu.cn/rust-static/rustup" /M
RsProxy.cn
setx RUSTUP_DIST_SERVER "https://rsproxy.cn" /M
setx RUSTUP_UPDATE_ROOT "https://rsproxy.cn/rustup" /M
C:\Users\Administrator.cargo\config
中国科技大学:
[source.crates-io]
registry ="https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
RsProxy.cn
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
CentOS7
在 CentOS 7 中配置 Rust 及 Rustup 使用国内镜像,可以按照以下步骤进行:
1. 安装 Rustup 并设置 Minimal Profile
首先修用下面的命令,将安装脚本导出
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs > rust.sh
打开 rust.sh 脚本,将 RUSTUP_UPDATE_ROOT 修改为
RUSTUP_UPDATE_ROOT="https://mirrors.aliyun.com/rustup/rustup/"
这是用来下载 rustup-init 的, 修改后通过国内镜像下载
chmod +x ./rust.sh
最后执行修改后的rust.sh
rustup set profile minimal
2. 配置 Rustup 使用国内源
(1)中国科技大学镜像
echo 'export RUSTUP_DIST_SERVER="https://mirrors.ustc.edu.cn/rust-static"' >> ~/.bashrc
echo 'export RUSTUP_UPDATE_ROOT="https://mirrors.ustc.edu.cn/rust-static/rustup"' >> ~/.bashrc
source ~/.bashrc
(2)RsProxy.cn 镜像
echo 'export RUSTUP_DIST_SERVER="https://rsproxy.cn"' >> ~/.bashrc
echo 'export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"' >> ~/.bashrc
source ~/.bashrc
3. 配置 Cargo 使用国内源
编辑 ~/.cargo/config
文件:
(1)中国科技大学镜像
mkdir -p ~/.cargo
cat > ~/.cargo/config <<EOF
[source.crates-io]
registry ="https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
EOF
(2)RsProxy.cn 镜像
mkdir -p ~/.cargo
cat > ~/.cargo/config <<EOF
[source.crates-io]
replace-with = 'rsproxy-sparse'
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"
[source.rsproxy-sparse]
registry = "sparse+https://rsproxy.cn/index/"
[registries.rsproxy]
index = "https://rsproxy.cn/crates.io-index"
[net]
git-fetch-with-cli = true
EOF
4. 更新 Rust 并验证
rustup update
rustc --version
cargo --version
这套配置可以帮助你在 CentOS 7 上顺利使用国内源加速 Rust 及 Cargo 相关的操作。你可以选择 USTC 或 RsProxy 作为镜像源,二者选其一即可。