通常 cargo 跑得挺順暢,不怎麼需要 proxy。但有備無患。
crates.io 和 rustup 的國內鏡像源#
字節跳動提供的:https://rsproxy.cn/
中國科技大學的:https://mirrors.ustc.edu.cn/help/crates.io-index.html
清華大學的:https://mirrors.tuna.tsinghua.edu.cn/help/rustup/
上海交通大學的:https://git.sjtu.edu.cn/sjtug/crates.io-index
更換國內源#
更換為國內源,否則安裝太慢了。
新建文件:~/.cargo/config,內容替換為如下,replace-with 這行可自己 ping 文件中各個國內源頭,看哪個源快用哪個:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 替換成你偏好的鏡像源
replace-with = 'sjtu'
# 清華大學
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# 中國科學技術大學
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# 上海交通大學
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc社區
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
# 字節跳動
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"