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快速搭建Markdown笔记发布系统

《利用Python快速搭建Markdown笔记发布系统》这篇文章主要为大家详细介绍了使用Python生态的成熟工具,在30分钟内搭建一个支持Markdown渲染、分类标签、全文搜索的私有化知识发布系统... 目录引言:为什么要自建知识博客一、技术选型:极简主义开发栈二、系统架构设计三、核心代码实现(分步解析

如何解决mmcv无法安装或安装之后报错问题

《如何解决mmcv无法安装或安装之后报错问题》:本文主要介绍如何解决mmcv无法安装或安装之后报错问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录mmcv无法安装或安装之后报错问题1.当我们运行YOwww.chinasem.cnLO时遇到2.找到下图所示这里3.

浅谈配置MMCV环境,解决报错,版本不匹配问题

《浅谈配置MMCV环境,解决报错,版本不匹配问题》:本文主要介绍浅谈配置MMCV环境,解决报错,版本不匹配问题,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录配置MMCV环境,解决报错,版本不匹配错误示例正确示例总结配置MMCV环境,解决报错,版本不匹配在col

Python通过模块化开发优化代码的技巧分享

《Python通过模块化开发优化代码的技巧分享》模块化开发就是把代码拆成一个个“零件”,该封装封装,该拆分拆分,下面小编就来和大家简单聊聊python如何用模块化开发进行代码优化吧... 目录什么是模块化开发如何拆分代码改进版:拆分成模块让模块更强大:使用 __init__.py你一定会遇到的问题模www.

Python 安装和配置flask, flask_cors的图文教程

《Python安装和配置flask,flask_cors的图文教程》:本文主要介绍Python安装和配置flask,flask_cors的图文教程,本文通过图文并茂的形式给大家介绍的非常详细,... 目录一.python安装:二,配置环境变量,三:检查Python安装和环境变量,四:安装flask和flas

Spring Security基于数据库的ABAC属性权限模型实战开发教程

《SpringSecurity基于数据库的ABAC属性权限模型实战开发教程》:本文主要介绍SpringSecurity基于数据库的ABAC属性权限模型实战开发教程,本文给大家介绍的非常详细,对大... 目录1. 前言2. 权限决策依据RBACABAC综合对比3. 数据库表结构说明4. 实战开始5. MyBA

使用Python自建轻量级的HTTP调试工具

《使用Python自建轻量级的HTTP调试工具》这篇文章主要为大家详细介绍了如何使用Python自建一个轻量级的HTTP调试工具,文中的示例代码讲解详细,感兴趣的小伙伴可以参考一下... 目录一、为什么需要自建工具二、核心功能设计三、技术选型四、分步实现五、进阶优化技巧六、使用示例七、性能对比八、扩展方向建

使用Python开发一个简单的本地图片服务器

《使用Python开发一个简单的本地图片服务器》本文介绍了如何结合wxPython构建的图形用户界面GUI和Python内建的Web服务器功能,在本地网络中搭建一个私人的,即开即用的网页相册,文中的示... 目录项目目标核心技术栈代码深度解析完整代码工作流程主要功能与优势潜在改进与思考运行结果总结你是否曾经

Linux中的计划任务(crontab)使用方式

《Linux中的计划任务(crontab)使用方式》:本文主要介绍Linux中的计划任务(crontab)使用方式,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录一、前言1、linux的起源与发展2、什么是计划任务(crontab)二、crontab基础1、cro

Win11安装PostgreSQL数据库的两种方式详细步骤

《Win11安装PostgreSQL数据库的两种方式详细步骤》PostgreSQL是备受业界青睐的关系型数据库,尤其是在地理空间和移动领域,:本文主要介绍Win11安装PostgreSQL数据库的... 目录一、exe文件安装 (推荐)下载安装包1. 选择操作系统2. 跳转到EDB(PostgreSQL 的