Rust更換Crates源

Rust編譯時遇到以下問題:html

Downloading futures v0.1.19
warning: spurious network error (2 tries remaining): [28] Timeout was reached (Operation timed out after 30857 milliseconds with 0 out of 0 bytes received)
error: unable to get packages from source                                       

Caused by:
  [35] SSL connect error (OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to static.crates.io:443 )

解決辦法:更換Crates源git

Rust開發時有時使用官方的源太慢,能夠考慮更換使用國內中科大的源。更換方法以下:code

$HOME/.cargo/config 中添加以下內容:htm

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

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

若是所處的環境中不容許使用 git 協議,能夠把上述地址改成:開發

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

爲何這麼配置能夠參考The Cargo Book/Source Replacement.rem

參考文檔:
The Cargo Book/Source Replacement
The Cargo Book/Configuration
Rust Crates 源使用幫助文檔

相關文章
相關標籤/搜索