ubuntu install rust

https://zhuanlan.zhihu.com/p/136848439基础上完善

1、进入rust网址下载对应的x86_64-unknown-linux-gnu 安装文件

https://forge.rust-lang.org/infra/other-installation-methods.html#which

2、chmod +x 777 rustup-init

./rustup-init

source ~/.cargo/env

3、/etc/profile中增加以下环境变量


export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static
export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup
export PATH=~/.cargo/bin:$PATH
export CARGO_HTTP_MULTIPLEXING=false

source /etc/profile

另外也可以使用rproxy镜像加速下载:

export RUSTUP_DIST_SERVER=https://rsproxy.cn
export RUSTUP_UPDATE_ROOT=https://rsproxy.cn/rustup

在 ~/.cargo/下新建一个文件config加入以下内容

[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"
[http]
check-revoke = false
                     

4. use nightly channel

rustup default nightly

5. Install rust grammar related components

rustup component add rls-preview rust-analysis rust-src
cargo install racer

6. Install rust-analyzer

2020-02-19, update. no need to install rust-analyzer by cargo. install it in vscode plugin, and it will download compiled binary of rust-analyzer.

#no need to install it by following method
git clone https://github.com/rust-analyzer/rust-analyzer.git --depth 1
cd rust-analyzer
cargo install-ra

7. The nightly channel need to kept updated, if encounter internal errors from rustc compiler, update the nightly channel may fix the problem.

rustup update

8. install several plugins including for vscode

Firefox quantum theme is the best theme for rust programming. It turn mut variable into red, a good one.

9. Fira Code Retina with bold font is good for eyes.

11. When the USTC mirror does not work, switch to tsinghua mirror, add following lines into ~/.cargo/config

[source.crates-io]
registry = "https://github.com/rust-lang/crates.io-index"
#replace-with = 'ustc'
replace-with = 'tuna'

[source.ustc]
registry = "git://mirrors.ustc.edu.cn/crates.io-index"
[source.tuna]
registry = "https://mirrors.tuna.tsinghua.edu.cn/git/crates.io-index.git"

Useful command tools written in Rust

  1. An useful shell prompt tool starship, install it by
cargo install starship
# in config.fish
starship init fish | source

2. Alternatives to du, ls, cat, grep and more

cargo install rg fd-find du-dust csvtk lsd bat ripgrep

setenv MANPAGER "sh -c 'col -bx | batcat -l man -p'
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值