Windows-2023安装最新版Rust

安装Rust有好几种方式,从官网下载安装文件直接无脑下一步就可以安装。
但是这种方式不能指定安装目录,这当然不行所以有了这篇自定义安装。

准备

在想要安装的地方建立两个文件夹,一个是==.rustup==,一个是==.cargo==就像这样。

image.png

然后添加到环境变量中,就像这样。
image.png
image.png

在Path中加入

  • %CARGO_HOME%
  • %RUSTUP_HOME%
    就像这样:
    image.png

安装

点击在官网下载的安装器rustup-init.exe。

Rust Visual C++ prerequisites

Rust requires a linker and Windows API libraries but they don't seem to be
available.

These components can be acquired through a Visual Studio installer.

1) Quick install via the Visual Studio Community installer
   (free for individuals, academic uses, and open source).

2) Manually install the prerequisites
   (for enterprise and advanced users).

3) Don't install the prerequisites
   (if you're targetting the GNU ABI).

>2


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:\WorkSpace\Rust_environment\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\WorkSpace\Rust_environment\.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:\WorkSpace\Rust_environment\.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 installation (default)
2) Customize installation
3) Cancel installation
>2 

I'm going to ask you the value of each of these installation options.
You may simply press the Enter key to leave unchanged.

Default host triple? [x86_64-pc-windows-msvc]
x86_64-pc-windows-gnu #修改为x86_64-pc-windows-gnu

Default toolchain? (stable/beta/nightly/none) [stable]
stable 

Profile (which tools and data to install)? (minimal/default/complete) [default]
default 

Modify PATH variable? (Y/n)
Y 


Current installation options:


   default host triple: x86_64-pc-windows-gnu
     default toolchain: stable
               profile: default
  modify PATH variable: yes

1) Proceed with installation (default)
2) Customize installation
3) Cancel installation
>1 

info: profile set to 'default'
info: setting default host triple to x86_64-pc-windows-gnu
info: syncing channel updates for 'stable-x86_64-pc-windows-gnu'
info: latest update on 2022-11-03, rust version 1.65.0 (897e37553 2022-11-02)
info: downloading component 'cargo'
  7.3 MiB /   7.3 MiB (100 %)   3.1 MiB/s in  2s ETA:  0s
info: downloading component 'clippy'
  3.7 MiB /   3.7 MiB (100 %)   2.8 MiB/s in  1s ETA:  0s
info: downloading component 'rust-docs'
 18.9 MiB /  18.9 MiB (100 %)   3.1 MiB/s in  6s ETA:  0s
info: downloading component 'rust-mingw'
  4.2 MiB /   4.2 MiB (100 %)   3.2 MiB/s in  1s ETA:  0s
info: downloading component 'rust-std'
 28.1 MiB /  28.1 MiB (100 %)   2.9 MiB/s in  9s ETA:  0s
info: downloading component 'rustc'
 74.0 MiB /  74.0 MiB (100 %)   3.1 MiB/s in 25s ETA:  0s
info: downloading component 'rustfmt'
  6.6 MiB /   6.6 MiB (100 %)   3.1 MiB/s in  2s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 18.9 MiB /  18.9 MiB (100 %)   1.8 MiB/s in 12s ETA:  0s
info: installing component 'rust-mingw'
info: installing component 'rust-std'
 28.1 MiB /  28.1 MiB (100 %)  13.5 MiB/s in  2s ETA:  0s
info: installing component 'rustc'
 74.0 MiB /  74.0 MiB (100 %)  13.9 MiB/s in  9s ETA:  0s
info: installing component 'rustfmt'
info: default toolchain set to 'stable-x86_64-pc-windows-gnu'

  stable-x86_64-pc-windows-gnu installed - rustc 1.65.0 (897e37553 2022-11-02)


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.

验证

使用cmd输入cargo --version,` rustc -V
出来版本好则安装成功!!
image.png

[!good]
帅,奖励自己一下吧!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值