The network in China is not well connected to the rest of the world. We have repository proxy for maven, for pypi, for yarn and so on. Do we have a repository proxy for crates.io
?
There are two mirrors that I know of:
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
registry = "sparse+https://mirrors.tuna.tsinghua.edu.cn/crates.io-index/"
To use the mirror, edit or create $CARGO_HOME/config
file like the following:
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index/"
In Linux, you can try the following command to change the configuration:
mkdir -vp ${CARGO_HOME:-$HOME/.cargo}
cat << EOF | tee -a ${CARGO_HOME:-$HOME/.cargo}/config
[source.crates-io]
replace-with = 'ustc'
[source.ustc]
registry = "sparse+https://mirrors.ustc.edu.cn/crates.io-index"
EOF
In Windows, the default path to $CARGO_HOME is C:\Users\<USERNAME>\.cargo
.
Note that sparse registries are supported from Rust 1.68+. It is recommended to use them if you can, since they are much faster. If it is not supported for your environment, try the git registry:
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
Or, if git cannot be used, try the following:
registry = "https://mirrors.ustc.edu.cn/crates.io-index"