Rust crates.io 索引

使用方法
编辑 $CARGO_HOME/config.toml 文件,添加以下内容:

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

[source.mirror]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
注:$CARGO_HOME:在 Windows 系统默认为:%USERPROFILE%\.cargo,在类 Unix 系统默认为:$HOME/.cargo。

注:cargo 仍会尝试读取不带 .toml 扩展名的配置文件(即 $CARGO_HOME/config),但从 1.39 版本起,cargo 引入了对 .toml 扩展名的支持,并将其设为首选格式。请根据使用的 cargo 版本选择适当的配置文件名。

在 Linux 环境可以使用下面的命令完成:

mkdir -vp ${CARGO_HOME:-$HOME/.cargo}

cat << EOF | tee -a ${CARGO_HOME:-$HOME/.cargo}/config.toml
[source.crates-io]
replace-with = 'mirror'

[source.mirror]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
EOF
在可能的情况下推荐使用 Rust crates.io 稀疏索引镜像

评论

等风等雨等你来