当前位置:   article > 正文

配置cargo国内源_cargo 国内源

cargo 国内源

1,配置cargo国内源

env RUSTFLAGS="-C target-cpu=native -g" FFI_BUILD_FROM_SOURCE=1 make clean all
  • 1
  • Updating crates.io index更新慢
+ local '__rust_flags=--print native-static-libs -C target-feature=+sse4.1,+sse4.2,+avx,+avx2,+sse2,+sha,+adx,'
+ RUSTFLAGS='--print native-static-libs -C target-feature=+sse4.1,+sse4.2,+avx,+avx2,+sse2,+sha,+adx,'
+ cargo +nightly-2020-03-19 build --release
+ tee /storage/lotuswork/tmpdir/tmp.ycbzTmDKrQ
    Updating crates.io index
  • 1
  • 2
  • 3
  • 4
  • 5
  • /root/.cargo新建配置文件config
  • cat /root/.cargo/config
[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
  • 1
  • 2
  • 3
  • 4
  • 5
# cargo install cargo-rls-install

  • 1
  • 2
  • 默认y
# cargo rls-install -i nightly-2020-03-19
# rustc -V
rustc 1.44.0-nightly (f509b26a7 2020-03-18)
  • 1
  • 2
  • 3

2,使用ustc源

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

[source.ustc]
registry = "https://mirrors.ustc.edu.cn/crates.io-index"
  • 1
  • 2
  • 3
  • 4
  • 5

3,国内安装

export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
  • 1
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
  • 1
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • 1
source $HOME/.cargo/env
  • 1

更新版本

rustup update
  • 1

nightly 切换版本

rustup default nightly
  • 1
vim ~/.cargo/config
  • 1
[source.crates-io]
replace-with = 'tuna'

[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"
  • 1
  • 2
  • 3
  • 4
  • 5

4. 配置 Cargo 国内镜像源

# cat /root/.cargo/config
[source.crates-io]
replace-with = 'ustc'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6

4.1 参考

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
# 指定镜像
replace-with = '镜像源名' # 如:tuna、sjtu、ustc,或者 rustcc

# 注:以下源配置一个即可,无需全部

# 中国科学技术大学
[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"

# 上海交通大学
[source.sjtu]
registry = "https://mirrors.sjtug.sjtu.edu.cn/git/crates.io-index"

# 清华大学
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

# rustcc社区
[source.rustcc]
registry = "https://code.aliyun.com/rustcc/crates.io-index.git"

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

参考:

  1. cargo-rls-install
  2. 配置 cargo 源
  3. Rust Cargo 的安装源替换
  4. Rust crates.io 索引镜像使用帮助 清华大学开源软件镜像站
  5. 配置 Cargo 国内镜像源
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/菜鸟追梦旅行/article/detail/484700
推荐阅读
相关标签
  

闽ICP备14008679号