Rust配置国内源,解决安装依赖慢问题

国内源使用字节的RsProxy https://rsproxy.cn/

配置环境变量

Mac

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

Windows

创建下面的系统环境变量

  1. 变量 RUSTUP_DIST_SERVER ,值 https://rsproxy.cn

  2. 变量 RUSTUP_UPDATE_ROOT ,值 https://rsproxy.cn/rustup

添加配置

新建配置文件

若对应的位置不存在 config 或者 config.toml 文件,手动新建即可。

  • Mac位置 ~/.cargo/config

  • Win位置 C:\Users\你的PC名\.cargo\config

配置文件内容如下【二选一】

[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
[source.crates-io]
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
文章作者: 小森森
本文链接:
版权声明: 本站所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 小森森博客
博客 经验
喜欢就支持一下吧
打赏
微信 微信
支付宝 支付宝