Rust installation special notes in China

From Rust Community Wiki
Revision as of 11:28, 13 July 2020 by 2a03:7500:7902:5a00:54b8:c8ff:feed:8a4 (talk) (Fix obvious typo)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Why?[edit | edit source]

Generally speaking, there's some strict auditing of Internet traffic in China, both on the content providers' side and service providers' side. None of Rust's major hosting services(rust-lang.org, crates.io, docs.rs, etc) can be classified as trusted here, since there isn't a representative legal body (like a company) participating the audition. These services are not banned either, since they're mostly technical content instead of arbitrary content (like what Google provides). So the actual use experiences will actually vary according to the ISPs in use. If you're working inside technical oriented offices, these services will generally work ok, but there could be connectivity issues now and then. If you're working from home, there's a chance that these services are almost entirely unusable.

How?[edit | edit source]

One way is to purchase some oversea proxy, if the proxy server is somehow classified more "trusted", the connectivity will be better. Usually it's not expensive to do so. However strictly speaking, this can be interpreted as illegal behavior.

Fortunately, there're other choices. The most useful ones are mirroring service. They provide mirrors to linux distros, homebrew and macports, and so on, for free. Some of them have also been providing Rust mirroring service since Rust has been becoming more popular. Most of the mirrors are provided and maintained by university campus technical leagues. They usually have great bandwidth, but have higher failure rates than the official service, so you'll want to make use of multiple services of them, and switch to another if one of them become unusable.

Some recommended choices[edit | edit source]

env var

RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static

.cargo/config

[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"

env var

RUSTUP_DIST_SERVER=https://mirrors.tuna.tsinghua.edu.cn/rustup

.cargo/config

[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

env var

RUSTUP_UPDATE_ROOT=https://mirrors.sjtug.sjtu.edu.cn/rust-static/rustup
RUSTUP_DIST_SERVER=https://mirrors.sjtug.sjtu.edu.cn/rust-static

.cargo/config

[source.crates-io]
replace-with = 'sjtu'

[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"