当前位置: 首页 > news >正文

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 secureWelcome 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/.rustupThis can be modified with the RUSTUP_HOME environment variable.The Cargo home directory is located at:/home/rust/.cargoThis 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/binThis 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/.bashrcYou 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-gnudefault toolchain: stable (default)profile: defaultmodify PATH variable: yes1) 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

http://www.lryc.cn/news/254535.html

相关文章:

  • 定义一个学生类,其中有3个私有数据成员学号、姓名、成绩,以及若于成员。 函数实现对学生数据的赋值和输出。
  • 1.2 C语言简介
  • 小白学Java之数组问题——第三关黄金挑战
  • 各大期刊网址
  • 使用autodl服务器,在A40显卡上运行, Yi-34B-Chat-int4模型,并使用vllm优化加速,显存占用42G,速度18 words/s
  • unity 2d 入门 飞翔小鸟 下坠功能且碰到地面要停止 刚体 胶囊碰撞器 (四)
  • 速达软件任意文件上传漏洞复现
  • Name or service not knownstname
  • [Geek Challenge 2023] web题解
  • 【recrutment / Hiring / Job / Application】
  • 二极管:ESD静电保护二极管
  • 【根据数组元素生成随机颜色函数】
  • 鸿蒙一出,android开发处境再受重创
  • ruoyi+Hadoop+hbase实现大数据存储查询
  • Word 在页眉或页脚中设置背景颜色
  • python获取js data.now同款时间戳
  • 线上超市小程序可以做什么活动_提升用户参与度与购物体验
  • 旺店通:API无代码开发的集成解决方案,连接电商平台、CRM和客服系统
  • 命令查询pg 数据库版本,并且分析结果行各代表什么意思
  • Elaticsearch 学习笔记
  • 计算机网络体系的形成
  • PyTorch 基础篇(1):Pytorch 基础
  • 掌握Selenium4:详解各种定位方式
  • go-fastfds部署心得
  • Python第三次练习
  • 从Java8升级到Java17,特色优化点
  • js实现富文本
  • 每日OJ题_算法_双指针②_力扣1089. 复写零
  • C++——红黑树
  • 【神化世界】asp网页500内部服务器错误的解决方法