Usually cargo runs smoothly without needing a proxy. But it's always good to have a backup plan.
Mirrors for crates.io and rustup in China#
Provided by ByteDance: https://rsproxy.cn/
Provided by University of Science and Technology of China: https://mirrors.ustc.edu.cn/help/crates.io-index.html
Provided by Tsinghua University: https://mirrors.tuna.tsinghua.edu.cn/help/rustup/
Provided by Shanghai Jiao Tong University: https://git.sjtu.edu.cn/sjtug/crates.io-index
Changing to a Chinese mirror#
Change to a Chinese mirror, otherwise the installation will be too slow.
Create a new file: ~/.cargo/config, and replace the content with the following. Replace the 'replace-with' line with the preferred mirror source by pinging each source in the file and choosing the fastest one:
[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# Replace with your preferred mirror source
replace-with = 'sjtu'
# Tsinghua University
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
# University of Science and Technology of China
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
# Shanghai Jiao Tong University
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"
# rustcc community
[source.rustcc]
registry = "git://crates.rustcc.cn/crates.io-index"
# ByteDance
[source.rsproxy]
registry = "https://rsproxy.cn/crates.io-index"