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

2023-12-05 08:36

本文主要是介绍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

这篇关于Linux下超轻量级Rust开发环境搭建:一、安装Rust的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/456863

相关文章

Python使用国内镜像加速pip安装的方法讲解

《Python使用国内镜像加速pip安装的方法讲解》在Python开发中,pip是一个非常重要的工具,用于安装和管理Python的第三方库,然而,在国内使用pip安装依赖时,往往会因为网络问题而导致速... 目录一、pip 工具简介1. 什么是 pip?2. 什么是 -i 参数?二、国内镜像源的选择三、如何

Linux使用nload监控网络流量的方法

《Linux使用nload监控网络流量的方法》Linux中的nload命令是一个用于实时监控网络流量的工具,它提供了传入和传出流量的可视化表示,帮助用户一目了然地了解网络活动,本文给大家介绍了Linu... 目录简介安装示例用法基础用法指定网络接口限制显示特定流量类型指定刷新率设置流量速率的显示单位监控多个

ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法

《ElasticSearch+Kibana通过Docker部署到Linux服务器中操作方法》本文介绍了Elasticsearch的基本概念,包括文档和字段、索引和映射,还详细描述了如何通过Docker... 目录1、ElasticSearch概念2、ElasticSearch、Kibana和IK分词器部署

Linux流媒体服务器部署流程

《Linux流媒体服务器部署流程》文章详细介绍了流媒体服务器的部署步骤,包括更新系统、安装依赖组件、编译安装Nginx和RTMP模块、配置Nginx和FFmpeg,以及测试流媒体服务器的搭建... 目录流媒体服务器部署部署安装1.更新系统2.安装依赖组件3.解压4.编译安装(添加RTMP和openssl模块

Android 悬浮窗开发示例((动态权限请求 | 前台服务和通知 | 悬浮窗创建 )

《Android悬浮窗开发示例((动态权限请求|前台服务和通知|悬浮窗创建)》本文介绍了Android悬浮窗的实现效果,包括动态权限请求、前台服务和通知的使用,悬浮窗权限需要动态申请并引导... 目录一、悬浮窗 动态权限请求1、动态请求权限2、悬浮窗权限说明3、检查动态权限4、申请动态权限5、权限设置完毕后

linux下多个硬盘划分到同一挂载点问题

《linux下多个硬盘划分到同一挂载点问题》在Linux系统中,将多个硬盘划分到同一挂载点需要通过逻辑卷管理(LVM)来实现,首先,需要将物理存储设备(如硬盘分区)创建为物理卷,然后,将这些物理卷组成... 目录linux下多个硬盘划分到同一挂载点需要明确的几个概念硬盘插上默认的是非lvm总结Linux下多

Python安装时常见报错以及解决方案

《Python安装时常见报错以及解决方案》:本文主要介绍在安装Python、配置环境变量、使用pip以及运行Python脚本时常见的错误及其解决方案,文中介绍的非常详细,需要的朋友可以参考下... 目录一、安装 python 时常见报错及解决方案(一)安装包下载失败(二)权限不足二、配置环境变量时常见报错及

linux进程D状态的解决思路分享

《linux进程D状态的解决思路分享》在Linux系统中,进程在内核模式下等待I/O完成时会进入不间断睡眠状态(D状态),这种状态下,进程无法通过普通方式被杀死,本文通过实验模拟了这种状态,并分析了如... 目录1. 问题描述2. 问题分析3. 实验模拟3.1 使用losetup创建一个卷作为pv的磁盘3.

MySQL8.2.0安装教程分享

《MySQL8.2.0安装教程分享》这篇文章详细介绍了如何在Windows系统上安装MySQL数据库软件,包括下载、安装、配置和设置环境变量的步骤... 目录mysql的安装图文1.python访问网址2javascript.点击3.进入Downloads向下滑动4.选择Community Server5.

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具