Rust语言设置国内镜像

字节跳动镜像

字节镜像

crates.io 镜像

~/.cargo/config:

[source.crates-io]
# To use sparse index, change 'rsproxy' to 'rsproxy-sparse'
replace-with = 'rsproxy'

[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

Rustup 镜像

export RUSTUP_DIST_SERVER="https://rsproxy.cn"
export RUSTUP_UPDATE_ROOT="https://rsproxy.cn/rustup"

安装 Rust

curl --proto '=https' --tlsv1.2 -sSf https://rsproxy.cn/rustup-init.sh | sh

Default host triple?

  • x86_64-pc-windows-gnu
  • x86_64-pc-windows-msvc

gnu => x86_64-posix-seh-rev0 才行,sljh版本的编译会失败

only Dwarf-2 (i686) and SEH (x86_64) exceptions are supported for windows-gnu toolchains.
URL

中科大镜像

{home}/.cargo/config

中科大镜像

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

环境变量:

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

Rust crates.io 稀疏索引镜像使用帮助

编辑 ~/.cargo/config 文件,添加以下内容:

[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"

注:sparse+ 表示在使用稀疏索引,链接末尾的 / 不能缺少。

截至目前,可以通过 cargo +nightly -Z sparse-registry update 使用稀疏索引。

cargo 1.68 版本开始支持稀疏索引:不再需要完整克隆 crates.io-index 仓库,可以加快获取包的速度。如果您的 cargo 版本大于等于 1.68,可以直接使用而不需要开启 nightly。

posted @ 2023-05-26 21:29  梅花Q  阅读(1172)  评论(0)    收藏  举报