Linux下超轻量级Rust开发环境搭建:一、安装Rust

Rust语言在国内逐步开始流行,但开发环境的不成熟依然困扰不少小伙伴。

结合我个人的使用体验,推荐一种超轻量级的开发环境:Rust + Helix Editor。运行环境需求很低,可以直接在Linux终端里进行代码开发。对于工程不是太过庞大的Rust项目,是一种不错的选择。

Linux环境下,先从Rust安装开始,流水帐。

我们选择从中国科学技术大学的镜像网站下载环境:

$> export RUSTUP_DIST_SERVER=https://mirrors.ustc.edu.cn/rust-static

$> export RUSTUP_UPDATE_ROOT=https://mirrors.ustc.edu.cn/rust-static/rustup

创建上面两个环境变量,让rustup的安装脚本从镜像站点下载开发环境:

$> curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

如果需要代理才能访问互联网,可以这样:

$> curl --proxy "socks5://ip:port" --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

ip是代理服务器的IP地址,port是代理服务器的端口。这里用的是的socks5的代理服务器。

info: downloading installer
Warning: Not enforcing strong cipher suites for TLS, this is potentially less secure

Welcome to Rust!

This will download and install the official compiler for the Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  /home/rust/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  /home/rust/.cargo

This can be modified with the CARGO_HOME environment variable.

The cargo, rustc, rustup and other commands will be added to
Cargo's bin directory, located at:

  /home/rust/.cargo/bin

This path will then be added to your PATH environment variable by
modifying the profile files located at:

  /home/rust/.profile
  /home/rust/.bash_profile
  /home/rust/.bashrc

You can uninstall at any time with rustup self uninstall and
these changes will be reverted.

Current installation options:


   default host triple: x86_64-unknown-linux-gnu
     default toolchain: stable (default)
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>

这里输入键盘回车即可。

我这里用的rust用户,所以目录都是/home/rust。

info: profile set to 'default'
info: default host triple is x86_64-unknown-linux-gnu
info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu'
info: latest update on 2023-11-16, rust version 1.74.0 (79e9716c9 2023-11-13)
info: downloading component 'cargo'
  8.2 MiB /   8.2 MiB (100 %)   1.1 MiB/s in  7s ETA:  0s
info: downloading component 'clippy'
  2.4 MiB /   2.4 MiB (100 %)   1.1 MiB/s in  2s ETA:  0s
info: downloading component 'rust-docs'
 14.4 MiB /  14.4 MiB (100 %)   1.1 MiB/s in 13s ETA:  0s
info: downloading component 'rust-std'
 26.3 MiB /  26.3 MiB (100 %)   1.1 MiB/s in 24s ETA:  0s
info: downloading component 'rustc'
 58.7 MiB /  58.7 MiB (100 %)   1.1 MiB/s in 52s ETA:  0s
info: downloading component 'rustfmt'
  2.4 MiB /   2.4 MiB (100 %)   1.2 MiB/s in  2s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 14.4 MiB /  14.4 MiB (100 %)   6.2 MiB/s in  2s ETA:  0s
info: installing component 'rust-std'
 26.3 MiB /  26.3 MiB (100 %)  10.0 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 58.7 MiB /  58.7 MiB (100 %)  11.1 MiB/s in  5s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-unknown-linux-gnu'

  stable-x86_64-unknown-linux-gnu installed - rustc 1.74.0 (79e9716c9 2023-11-13)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload your PATH environment variable to include
Cargo's bin directory ($HOME/.cargo/bin).

To configure your current shell, run:
source "$HOME/.cargo/env"
[rust@selfservice ~]$ 

按提示,运行一下:source "$HOME/.cargo/env"。

使用rustup命令再安装两个组件:

$> rustup component add rust-src
$> rustup component add rust-analyzer

这个Rust开发环境就安装成功了。

下一步:

Linux下超轻量级Rust开发环境搭建:二、安装Helix Editor

相关推荐

  1. Linux轻量级Rust开发环境安装Rust

    2023-12-08 01:30:01       38 阅读
  2. linux系统vscode portable版本的rust环境003:rust

    2023-12-08 01:30:01       32 阅读
  3. Rust介绍与开发环境

    2023-12-08 01:30:01       30 阅读

最近更新

  1. TCP协议是安全的吗?

    2023-12-08 01:30:01       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2023-12-08 01:30:01       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2023-12-08 01:30:01       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2023-12-08 01:30:01       18 阅读

热门阅读

  1. python pandas dataframe常用数据处理总结

    2023-12-08 01:30:01       36 阅读
  2. 纯C读取文件实现解析H264裸流每一帧数据

    2023-12-08 01:30:01       44 阅读
  3. Redisson

    2023-12-08 01:30:01       43 阅读
  4. 算法 拓扑序列

    2023-12-08 01:30:01       29 阅读
  5. Redis默认序列化方式乱码原因及解决办法

    2023-12-08 01:30:01       42 阅读
  6. 计算机网络——传输层

    2023-12-08 01:30:01       39 阅读
  7. python模块 — json

    2023-12-08 01:30:01       42 阅读
  8. TCP_NODELAY与TCP通信效率

    2023-12-08 01:30:01       43 阅读
  9. 【算法】合并K个升序链表

    2023-12-08 01:30:01       41 阅读
  10. Dynamo学习使用的网站

    2023-12-08 01:30:01       43 阅读
  11. 【NEON】学习资料汇总

    2023-12-08 01:30:01       43 阅读
  12. 【Centos8】配置网络镜像源

    2023-12-08 01:30:01       36 阅读