# Rust Crates 使用国内镜像

- Link: https://www.ixiqin.com/2019/02/24/rust-crates-use-mirror-at-home/
- Published: 2019-02-24T17:56:56+08:00
- Author: 白宦成

我在使用 Rust 安装 rls 时，出现了下载报错，具体如下

    ```wp-block-preformatted
    info: caused by: error during downloadinfo: caused by: [56] Failure when receiving data from the peer
    ```

一看到 _from the peer _，我就明白了，大概率被墙了。所以，就要切换为国内镜像源。

目前只有 USTC 提供了 Rust Crates 的镜像源,接下来，我们就开始配置 Rust Crates 源。

 https://servers.ustclug.org/2016/01/mirrors-add-rust-crates/

USTC Lug 的公告

## 配置 Mirror

使用 VSCode 打开配置文件 `$HOME/.cargo/config`

在其中加入如下代码

    ```javascript
    [source.crates-io]
    registry = "https://github.com/rust-lang/crates.io-index"
    replace-with = 'ustc'
    [source.ustc]
    registry = "git://mirrors.ustc.edu.cn/crates.io-index"
    Code language: JavaScript (javascript)
    ```

然后重新在命令行中执行安装代码，可以看到非常高效的完成了安装.

![](https://postimg.aliavv.com/201810/s2ym7.jpg)
