Rust編譯時遇到如下問題:
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源
Rust開發時有時使用官方的源太慢,可以考慮更換使用國內中科大的源。更換方法如下:
在 $HOME/.cargo/config
中添加如下內容:
[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.
參考文檔:
The Cargo Book/Source Replacement
The Cargo Book/Configuration
Rust Crates 源使用幫助