首页Rust文章详情

Rust cargo build 依赖无法构建完美解决方案

By liajitu / Mar 3, 2020 阅读 0 评论 0 发表于 Rust 字数:495 阅读时间:5秒

摘要:Rust 无法访问 crates.io,如何解决更换国内镜像源?

众所周知的原因,crates.io在国内访问十分糟糕,轻则编译缓慢,要很久很久,重则直接超时报错,编译不了.

> cargo build 

> Blocking waiting for file lock on package cache


第一步:进入当前用户所在目录下的 .cargo 目录

cd ~/.cargo

第二步:新创建 config 文件

vim config

第三步:写入以下内容

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
replace-with = 'ustc'
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

如果所处的环境中不允许使用 git 协议, 可以把

git://mirrors.ustc.edu.cn/crates.io-index

 改为

http://mirrors.ustc.edu.cn/crates.io-index

在加载依赖的时候,速度杠杠的!


 参考链接:https://crates.io/

手机扫码阅读,舒服~

⌘ + Return 发表
最新 最早 全部评论0 条评论