Cargo Config


Additional configs for cargo to solve access issue to creates.io. Change registry to China specific mirror and use the git executable to fetch registry contents instead of built-in git library.

First, create a config file under ~/.cargo folder. In Windows, that’s C:\Users\<username>\.cargo\config file. Then add following content to the config file:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
[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"
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

[net]
git-fetch-with-cli = true

Reference: Cargo configuration documentation