Rust 和 Cargo 安装指南

Rust 官网
在这里插入图片描述

双击下载下来的exe文件


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:

  C:\Users\M\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\Users\M\.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:

  C:\Users\M\.cargo\bin

This path will then be added to your PATH environment variable by
modifying the HKEY_CURRENT_USER/Environment/PATH registry key.

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

Current installation options:


   default host triple: x86_64-pc-windows-msvc
     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
>

这段文本是 Rust 安装程序的说明,它在告诉你 Rust 编译器和包管理工具 Cargo 的安装细节。这里是一些关键点的解释:

  1. 安装 Rust 编译器和 Cargo:安装程序将下载并安装 Rust 编程语言的官方编译器和它的包管理工具 Cargo。

  2. 安装位置

    • Rustup 的元数据和工具链将被安装在 C:\Users\M\.rustup 目录下,可以通过设置 RUSTUP_HOME 环境变量来修改这个位置。
    • Cargo 的主目录将被安装在 C:\Users\M\.cargo 目录下,可以通过设置 CARGO_HOME 环境变量来修改这个位置。
  3. 添加到系统路径

    • cargorustcrustup 等命令将被添加到 C:\Users\M\.cargo\bin 目录下。
    • 安装程序将通过修改注册表 HKEY_CURRENT_USER/Environment/PATH 来将这个路径添加到你的系统环境变量 PATH 中。
  4. 安装选项

    • 默认主机三元组是 x86_64-pc-windows-msvc,这是 Windows 系统上 Rust 的标准三元组。
    • 默认工具链是 stable,这是 Rust 的稳定版本。
    • 默认配置文件是 default
    • 是否修改 PATH 变量:是。
  5. 安装操作

      1. 使用标准安装(默认选项,只需按回车键)。
      1. 自定义安装。
      1. 取消安装。

你需要做什么

  • 如果你想要继续安装 Rust 和 Cargo,并且接受默认设置,只需按回车键。
  • 如果你需要更改安装设置(例如,改变安装位置或不修改 PATH 环境变量),选择 “2) Customize installation” 并进行相应的配置。
  • 如果你不想安装 Rust 和 Cargo,选择 “3) Cancel installation” 来取消安装过程。

通常,对于大多数用户来说,接受默认设置并按回车键继续安装是最简单的选择。

按回车,等待安装完成(如果用国内网的话会很慢,并且容易不成功)

info: profile set to 'default'
info: default host triple is x86_64-pc-windows-msvc
info: syncing channel updates for 'stable-x86_64-pc-windows-msvc'
info: latest update on 2024-05-02, rust version 1.78.0 (9b00956e5 2024-04-29)
info: downloading component 'cargo'
info: downloading component 'clippy'
info: downloading component 'rust-docs'
info: downloading component 'rust-std'
info: downloading component 'rustc'
 57.4 MiB /  57.4 MiB (100 %)  21.5 MiB/s in  2s ETA:  0s
info: downloading component 'rustfmt'
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 15.1 MiB /  15.1 MiB (100 %)   3.0 MiB/s in  4s ETA:  0s
info: installing component 'rust-std'
 18.0 MiB /  18.0 MiB (100 %)  18.0 MiB/s in  1s ETA:  0s
info: installing component 'rustc'
 57.4 MiB /  57.4 MiB (100 %)  18.1 MiB/s in  3s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-msvc'

  stable-x86_64-pc-windows-msvc installed - rustc 1.78.0 (9b00956e5 2024-04-29)


Rust is installed now. Great!

To get started you may need to restart your current shell.
This would reload its PATH environment variable to include
Cargo's bin directory (%USERPROFILE%\.cargo\bin).

Press the Enter key to continue.

在命令行中输入 cargo --version 或 rustc --version 来验证 Rust 和 Cargo 是否正确安装。这应该会显示已安装的版本信息。
在这里插入图片描述

  • 6
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
要在WSL2上安装Rust,您可以按照以下步骤进行操作: 1. 首先,确保您已经安装了WSL2并配置好了开发环境。如果您还没有安装WSL2,请按照引用或引用中的文章指南安装和设置WSL2。 2. 打开WSL2终端(Ubuntu),运行以下命令来更新软件包列表: ``` sudo apt update ``` 3. 接下来,安装构建工具和依赖项,可以使用以下命令: ``` sudo apt install build-essential ``` 4. 然后,您可以通过下载和运行Rust安装脚本来安装Rust。在终端中运行以下命令: ``` curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh ``` 这将自动下载并运行Rust安装脚本。按照提示选择默认选项进行安装。 5. 安装完成后,您需要将Rust工具链添加到您的环境变量中。在终端中运行以下命令: ``` source $HOME/.cargo/env ``` 这将使您能够在WSL2中使用Rust命令。 6. 最后,您可以验证Rust是否成功安装。在终端中运行以下命令: ``` rustc --version ``` 如果您成功安装Rust,您将看到Rust的版本信息。 现在,您已经在WSL2上成功安装Rust,并可以开始使用它进行开发了。祝您使用愉快!<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* [Rust : WSL下编程](https://download.csdn.net/download/weixin_38604951/14042184)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* *3* [wsl 安装 rust_在wsl2上调试rust代码](https://blog.csdn.net/weixin_26755331/article/details/108898821)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值