Rust更換Crates源


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 源使用幫助


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM