Rust更换Crates源

软件发布|下载排行|最新软件

当前位置:首页IT学院IT技术

Rust更换Crates源

让我思考一下   2019-11-29 我要评论

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

Copyright 2022 版权所有 软件发布 访问手机版

声明:所有软件和文章来自软件开发商或者作者 如有异议 请与本站联系 联系我们