安装Rust

Rust 是一种系统级编程语言,旨在提供高性能和内存安全,同时避免常见的编程错误。
由 Mozilla Research 推出,Rust 自推出以来因其独特的设计理念和强大的功能而在开发者社区中迅速获得了广泛的关注和采用。

curl --proto ‘=https’ --tlsv1.2 -sSf https://sh.rustup.rs | sh info: downloading installer

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/jjmczd/.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

/home/jjmczd/.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/jjmczd/.cargo/bin

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

/home/jjmczd/.profile /home/jjmczd/.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 standard installation (default - just press enter) 2)
    Customize installation 3) Cancel installation

命令解释

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

分解说明:

  1. curl:这是一个用于在命令行下传输数据的工具,支持多种协议(如 HTTP、HTTPS、FTP 等)。

  2. --proto '=https':指定只允许使用 HTTPS 协议进行传输,确保数据传输的安全性。

  3. --tlsv1.2:强制 curl 使用 TLS 1.2 协议,这是一种安全的传输层协议。

  4. -s:静默模式(silent),在执行过程中不会显示进度条或错误信息。

  5. -Sf

    • -S:当使用 -s(静默模式)时,-S 可以让 curl 在发生错误时仍然显示错误信息。
    • -f:如果服务器返回一个错误状态码(如 404),curl 会失败并返回一个错误,而不是输出错误页面的内容。
  6. https://sh.rustup.rs:这是 Rust 官方提供的安装脚本的 URL。

  7. | sh:管道符号(|)将前一个命令(curl)的输出传递给后一个命令(sh)。也就是说,下载的安装脚本将直接由 sh(shell)执行。

整体作用:
这个命令通过安全的 HTTPS 连接下载 Rust 的安装脚本,并立即在您的终端中执行该脚本,以便安装 Rust 编程语言及其工具链。

输出解释

info: downloading installerWelcome 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/jjmczd/.rustupThis can be modified with the RUSTUP_HOME environment variable.The Cargo home directory is located at:/home/jjmczd/.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/jjmczd/.cargo/binThis path will then be added to your PATH environment variable by
modifying the profile files located at:/home/jjmczd/.profile/home/jjmczd/.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 standard installation (default - just press enter)
2) Customize installation
3) Cancel installation

逐行解释:

  1. info: downloading installer

    • 解释:安装程序正在下载过程中。
  2. Welcome to Rust!

    • 解释:欢迎使用 Rust!
  3. 接下来的几行

    • 解释:这些行说明了安装过程将会下载和安装 Rust 官方编译器(rustc)以及其包管理器(Cargo)。
  4. Rustup metadata and toolchains will be installed into the Rustup home directory, located at:

    • 解释:Rustup 的元数据和工具链将被安装到指定的 Rustup 主目录中,默认路径为 /home/jjmczd/.rustup。您可以通过设置 RUSTUP_HOME 环境变量来修改此路径。
  5. The Cargo home directory is located at:

    • 解释:Cargo 的主目录位于 /home/jjmczd/.cargo。同样,您可以通过设置 CARGO_HOME 环境变量来修改此路径。
  6. The cargo, rustc, rustup and other commands will be added to Cargo's bin directory, located at:

    • 解释cargorustcrustup 以及其他相关命令将被添加到 Cargo 的 bin 目录中,即 /home/jjmczd/.cargo/bin
  7. This path will then be added to your PATH environment variable by modifying the profile files located at:

    • 解释:安装程序会将上述 bin 目录路径添加到您的 PATH 环境变量中,这通过修改您的 shell 配置文件(如 /home/jjmczd/.profile/home/jjmczd/.bashrc)来实现。这样,您可以在任何终端会话中直接运行 Rust 的命令。
  8. You can uninstall at any time with rustup self uninstall and these changes will be reverted.

    • 解释:如果您在任何时候想要卸载 Rust,可以运行 rustup self uninstall 命令,这将撤销所有安装的更改。
  9. Current installation options:

    • 解释:当前的安装选项如下:

    • default host triple: x86_64-unknown-linux-gnu

      • 解释:默认的主机三元组(host triple)是 x86_64-unknown-linux-gnu,表示安装的是适用于 64 位 Linux 系统的 Rust 工具链。
    • default toolchain: stable (default)

      • 解释:默认的工具链是 stable 版本,这是 Rust 的稳定版本,适合大多数用户和生产环境使用。
    • profile: default

      • 解释:使用的是默认的安装配置文件,包含基本的组件和设置。
    • modify PATH variable: yes

      • 解释:安装程序将修改您的 PATH 环境变量,以便您可以在终端中直接使用 Rust 的命令。
  10. 安装选项菜单:

    1) Proceed with standard installation (default - just press enter)
    2) Customize installation
    3) Cancel installation
    
    • 1) Proceed with standard installation (default - just press enter)

      • 解释:继续标准安装(默认选项)。如果您按回车键,将使用上述默认设置进行安装。
    • 2) Customize installation

      • 解释:自定义安装。选择此选项可以让您自定义安装路径、选择不同的工具链版本或调整其他安装选项。
    • 3) Cancel installation

      • 解释:取消安装。选择此选项将终止 Rust 的安装过程。

接下来的步骤

  1. 选择安装选项:

    • 标准安装:如果您不需要自定义安装,直接按回车键继续。这将使用默认设置进行安装。
    • 自定义安装:如果您需要更改安装路径或选择特定的工具链版本,可以输入 2 并按照提示进行操作。
    • 取消安装:如果您暂时不想安装 Rust,可以输入 3 取消。
  2. 完成安装:

    • 安装完成后,确保重新启动终端或重新加载 shell 配置文件,以便新的 PATH 设置生效。

    • 您可以通过运行以下命令来验证 Rust 是否安装成功:

      rustc --version
      cargo --version
      

      这两个命令应分别返回 Rust 编译器和 Cargo 的版本信息。

  3. 更新 Rust(可选):

    • 如果您已经安装过 Rust,可以通过以下命令更新到最新版本:

      rustup update
      

常见问题

  • PATH 环境变量未更新:
    如果安装后运行 rustc --version 提示找不到命令,可能是因为 PATH 环境变量未正确更新。您可以手动添加 Cargo 的 bin 目录到 PATH 中,例如:

    export PATH="$HOME/.cargo/bin:$PATH"
    

    将上述行添加到您的 ~/.bashrc~/.profile 文件中,然后重新加载配置:

    source ~/.bashrc
    
  • 卸载 Rust:
    如果需要卸载 Rust,可以运行以下命令:

    rustup self uninstall
    

    这将删除 Rustup 及其管理的所有工具链,并恢复 PATH 环境变量的更改。

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’
804.2 KiB / 804.2 KiB (100 %) 86.3 KiB/s in 10s ETA: 0s info: latest update on 2024-09-05, rust version 1.81.0 (eeb90cda1 2024-09-04) info:
downloading component ‘cargo’
8.3 MiB / 8.3 MiB (100 %) 243.2 KiB/s in 43s ETA: 0s info: downloading component ‘clippy’
2.6 MiB / 2.6 MiB (100 %) 488.2 KiB/s in 8s ETA: 0s info: downloading component ‘rust-docs’
15.9 MiB / 15.9 MiB (100 %) 962.2 KiB/s in 1m 13s ETA: 0s info: downloading component ‘rust-std’
26.8 MiB / 26.8 MiB (100 %) 298.8 KiB/s in 1m 37s ETA: 0s info: downloading component ‘rustc’
66.9 MiB / 66.9 MiB (100 %) 198.4 KiB/s in 9m 28s ETA: 0s info: downloading component ‘rustfmt’
2.4 MiB / 2.4 MiB (100 %) 438.4 KiB/s in 8s ETA: 0s info: installing component ‘cargo’ info: installing component ‘clippy’ info:
installing component ‘rust-docs’
15.9 MiB / 15.9 MiB (100 %) 5.8 MiB/s in 2s ETA: 0s info: installing component ‘rust-std’
26.8 MiB / 26.8 MiB (100 %) 14.7 MiB/s in 2s ETA: 0s info: installing component ‘rustc’
66.9 MiB / 66.9 MiB (100 %) 15.7 MiB/s in 4s 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.81.0 (eeb90cda1
2024-09-04)

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, you need to source the corresponding
env file under $HOME/.cargo.

This is usually done by running one of the following (note the leading
DOT): . “KaTeX parse error: Expected 'EOF', got '#' at position 29: …nv" #̲ For sh/bash/zs…HOME/.cargo/env.fish” # For fish
这个输出是关于在终端中安装 Rust 的详细日志。每一行解释如下:

  1. info: profile set to ‘default’
    Rust 安装时选择了默认的配置(profile),这意味着 Rust 会根据默认的设置安装其组件。这通常包括常用的工具,比如编译器和包管理器。

  2. info: default host triple is x86_64-unknown-linux-gnu
    这是 Rust 编译器的目标平台,也叫“三元组”(triple),这里指的是 64 位的 Linux 系统。x86_64-unknown-linux-gnu 表示编译器将生成适用于 64 位 Linux 系统的代码。

  3. info: syncing channel updates for ‘stable-x86_64-unknown-linux-gnu’
    Rust 的安装器正在同步最新的稳定版(stable channel)更新。这意味着它正在获取当前最新版本的稳定版 Rust 相关组件。

  4. 下载组件(cargo, clippy, rust-docs, rust-std, rustc, rustfmt)

    • cargo 是 Rust 的包管理工具,用于管理依赖和构建项目。
    • clippy 是一个 Rust 代码的静态分析工具,帮助开发者遵循最佳实践。
    • rust-docs 是 Rust 的文档,可以离线访问 Rust 标准库的文档。
    • rust-std 是标准库,Rust 编译时所需要的核心库。
    • rustc 是 Rust 编译器,负责将 Rust 源代码编译为可执行文件。
    • rustfmt 是代码格式化工具,用于确保 Rust 代码风格的一致性。
  5. info: installing component ‘cargo’
    系统开始安装上述下载的组件,如 cargoclippyrust-docs 等。

  6. info: default toolchain set to ‘stable-x86_64-unknown-linux-gnu’
    系统设置了默认的 Rust 工具链为稳定版,即用户将使用稳定版的 Rust 编译器和工具。

  7. Rust is installed now. Great!
    Rust 安装成功,已经准备好使用。

  8. To get started you may need to restart your current shell.
    建议用户重启当前的终端会话,或重新加载终端,以确保 $HOME/.cargo/bin 路径被正确添加到 PATH 环境变量中。

  9. To configure your current shell, you need to source…
    这一行提示如何在当前 shell 中手动加载 Rust 环境,可以运行以下命令:

    . "$HOME/.cargo/env"    # 对于 bash、zsh 等 shell
    

    或者:

    source "$HOME/.cargo/env.fish"  # 对于 fish shell
    

通过这些步骤,Rust 及其工具链已经成功安装,可以开始使用 Rust 开发了。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/881035.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Python或R时偏移算法实现

🎯要点 计算单变量或多变量时序距离,使用欧几里得、曼哈顿等函数量化不同时序差异。量化生成时序之间接近度相似性矩阵。使用高尔距离和堪培拉距离等相似度测量。实现最小方差匹配算法,绘制步进模式的图形表示。其他语言包算法实现。 &…

【AI知识点】NP 难问题(NP-Hard Problem)

NP 难问题(NP-Hard Problem) 是计算复杂性理论中的一个重要概念,描述了那些非常难以求解的问题。NP 难问题中的“NP”代表“非确定性多项式时间”(Nondeterministic Polynomial time)。这些问题的特性使得求解它们的最…

[uni-app]小兔鲜-07订单+支付

订单模块 基本信息渲染 import type { OrderState } from /services/constants import type { AddressItem } from ./address import type { PageParams } from /types/global/** 获取预付订单 返回信息 */ export type OrderPreResult {/** 商品集合 [ 商品信息 ] */goods: …

[数据集][目标检测]辣椒缺陷检测数据集VOC+YOLO格式695张5类别

重要说明:数据集图片里面都是一个辣椒,请仔细查看图片预览,确认符合要求下载 数据集格式:Pascal VOC格式YOLO格式(不包含分割路径的txt文件,仅仅包含jpg图片以及对应的VOC格式xml文件和yolo格式txt文件) 图片数量(jpg文…

jenkins 构建报错ERROR: Error fetching remote repo ‘origin‘

问题描述 修改项目的仓库地址后,使用jenkins构建报错 Running as SYSTEM Building in workspace /var/jenkins_home/workspace/【测试】客户端/client-fonchain-main The recommended git tool is: NONE using credential 680a5841-cfa5-4d8a-bb38-977f796c26dd&g…

小白快速上手 Docker 03 | Docker数据卷

数据卷 在前面使用Docker时,可能会遇到以下几个问题: 当Docker 里的容器挂了以后打不开,这时候只有删除该容器了,但删除容器会连容器中的产生的数据也一起删除了,大部分场景下这是不能接受的。Docker容器与容器之间不…

【图论】1 (最小生成树虚拟点思想)C.戴森球计划 题解

一. 题目 题目描述 输入输出格式 样例 样例1 样例2 & 样例解释 数据范围 二. 思路 对于前20%数据 解法 因为保证了 x i 1 x_i 1 xi​1,也就是说这些点都在 x 1 x 1 x1 这条直线上。 那么最优解必定是在 c i c_i ci​ 最小的点上建发电站&#xff0c…

4.人员管理模块(开始预备工作)——帝可得管理系统

目录 前言一、需求分析1.页面原型2.创建SQL 二、使用若依框架生成前后端代码1.添加目录菜单2.添加数据字典3.配置代码生成信息4.下载代码并导入项目5.快速导入方法 三、 总结 前言 提示:本篇讲解人员管理模块的开发的预备工作,包括需求分析、生成代码、…

uniapp+Android面向网络学习的时间管理工具软件 微信小程序

目录 项目介绍支持以下技术栈:具体实现截图HBuilderXuniappmysql数据库与主流编程语言java类核心代码部分展示登录的业务流程的顺序是:数据库设计性能分析操作可行性技术可行性系统安全性数据完整性软件测试详细视频演示源码获取方式 项目介绍 用户功能…

最新版本SkyWalking【10.1.0】部署

这里写目录标题 前言前置条件启动Skywalking下载解压启动说明 集成Skywalking Agent下载Agent在IDEA中添加agent启动应用并访问SpringBoot接口 说明 前言 基于当前最新版10.1.0搭建skywalking 前置条件 装有JDK11版本的环境了解SpringBoot相关知识 启动Skywalking 下载 地…

golang grpc进阶

protobuf 官方文档 基本数据类型 .proto TypeNotesGo Typedoublefloat64floatfloat32int32使用变长编码,对于负值的效率很低,如果你的域有可能有负值,请使用sint64替代int32uint32使用变长编码uint32uint64使用变长编码uint64sint32使用变长…

Linux:无法为立即文档创建临时文件: 设备上没有空间

虚拟机磁盘空间不足解决记录 1、问题描述2、问题解决 1、问题描述 在命令行输入命令按Tab键时出现如下报错: 很明显,设备上没有空间,即磁盘空间不足。通过命令查看具体情况如下: df -h2、问题解决 首先想到的是虚拟机扩容。关机虚…

每日学习一个数据结构-树

文章目录 树的相关概念一、树的定义二、树的基本术语三、树的分类四、特殊类型的树五、树的遍历六、树的应用场景 树的遍历一、前序遍历二、中序遍历三、后序遍历使用java代码实现遍历总结 树的相关概念 树是一种重要的非线性数据结构,在计算机科学中有着广泛的应用…

C++IO流

个人主页:C忠实粉丝 欢迎 点赞👍 收藏✨ 留言✉ 加关注💓本文由 C忠实粉丝 原创 CIO流 收录于专栏 [C进阶学习] 本专栏旨在分享学习C的一点学习笔记,欢迎大家在评论区交流讨论💌 目录 1. C语言的输入与输出 2. 流是什…

(PyTorch) 深度学习框架-介绍篇

前言 在当今科技飞速发展的时代,人工智能尤其是深度学习领域正以惊人的速度改变着我们的世界。从图像识别、语音处理到自然语言处理,深度学习技术在各个领域都取得了显著的成就,为解决复杂的现实问题提供了强大的工具和方法。 PyTorch 是一个…

C语言基础(7)之操作符(1)(详解)

目录 1. 各种操作符介绍 1.1 操作符汇总表 2. 移位操作符 2.1 移位操作符知识拓展 —— 原码、反码、补码 2.2 移位操作符讲解 2.2.1 右移操作符 ( >> ) 2.2.2 左移操作符 ( << ) 3. 位操作符 3.1 & (按位与) 3.2 | (按位或) 3.3 ^ (按位异或) 3.4…

深度学习每周学习总结J1(ResNet-50算法实战与解析 - 鸟类识别)

&#x1f368; 本文为&#x1f517;365天深度学习训练营 中的学习记录博客&#x1f356; 原作者&#xff1a;K同学啊 | 接辅导、项目定制 目录 0. 总结1. 设置GPU2. 导入数据及处理部分3. 划分数据集4. 模型构建部分5. 设置超参数&#xff1a;定义损失函数&#xff0c;学习率&a…

Python 解析 html

一、场景分析 假设有如下 html 文档&#xff1a; 写一段 python 脚本&#xff0c;解析出里面的数据&#xff0c;包括经度维度。 <div classstorelist><ul><li lng"100.111111" lat"10.111111"><h4>联盟店1</h4><p>…

【C语言】数组练习

【C语言】数组练习 练习1&#xff1a;多个字符从两端移动&#xff0c;向中间汇聚练习2、二分查找 练习1&#xff1a;多个字符从两端移动&#xff0c;向中间汇聚 编写代码&#xff0c;演示多个字符从两端移动&#xff0c;向中间汇聚 练习2、二分查找 在⼀个升序的数组中查找指…

--- java数据结构 map set ---

java中map 和 set的底层实现是通过搜索树和哈希函桶来实现 搜索树 二叉搜索树有叫二叉排序树 他具有以下的特点 若存在左节点&#xff0c;那么他左节点的值一定小于根节点 若存在右节点&#xff0c;那么他右节点的值一定大于根节点 它的左右子树也是搜索树 对他进行中序…