This tutorial covers the following things

  • How to install rust in windows
  • Uninstall rust in windows
  • How to check the rust version using the command line
  • Rust upgrade to the latest version

Rust installation is managed by the tool Rustup.

Installation of rust setup installs the following tools

  • Rustc : rust compiler
  • cargo : Rust package management tool
  • rustup: toolchain manager tool for installing and uninstalling rust environment

rustc and cargo are shipped as a single and installed when you install the rust installer.

First, download the installer from [here]https://www.rust-lang.org/tools/install, It downloads a rustup-init.exe file.

Click on this file, It opens the console with the below option

Welcome to Rust!

This will download and install the official compiler for Rust
programming language, and its package manager, Cargo.

Rustup metadata and toolchains will be installed into the Rustup
home directory, located at:

  C:\Users\user\.rustup

This can be modified with the RUSTUP_HOME environment variable.

The Cargo home directory is located at:

  C:\Users\user\.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, and located at:

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

Select Option 1) to install with default settings

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

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 2022-04-07, rust version 1.60.0 (7737e0b5c 2022-04-04)
info: downloading component 'cargo'
  3.9 MiB /   3.9 MiB (100 %)   3.7 MiB/s in  1s ETA:  0s
info: downloading component 'clippy'
info: downloading component 'rust-docs'
 19.6 MiB /  19.6 MiB (100 %)   2.6 MiB/s in  7s ETA:  0s
info: downloading component 'rust-std'
 24.0 MiB /  24.0 MiB (100 %)   3.3 MiB/s in  8s ETA:  0s
info: downloading component 'rustc'
 56.7 MiB /  56.7 MiB (100 %)   1.6 MiB/s in 25s ETA:  0s
info: downloading component 'rustfmt'
  2.2 MiB /   2.2 MiB (100 %)   1.6 MiB/s in  2s ETA:  0s
info: installing component 'cargo'
info: installing component 'clippy'
info: installing component 'rust-docs'
 19.6 MiB /  19.6 MiB (100 %) 673.6 KiB/s in  2m  5s ETA:  0s
info: installing component 'rust-std'
 24.0 MiB /  24.0 MiB (100 %)   6.2 MiB/s in 10s ETA:  0s
info: installing component 'rustc'
 56.7 MiB /  56.7 MiB (100 %)   7.3 MiB/s in 12s 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.60.0 (7737e0b5c 2022-04-04)


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.

Check whether rust is installed or not with the version list

C:\>rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)

C:\>cargo --version
cargo 1.60.0 (d1fd9fe2c 2022-03-01)

C:\>rustup --version
rustup 1.24.3 (ce5817a94 2021-05-31)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: The currently active `rustc` version is `rustc 1.60.0 (7737e0b5c 2022-04-04)`

How to uninstall rust in windows

Type the below command in the terminal.

rustup self uninstall

It uninstalls rust from your machine.

How to upgrade rust to the latest version?

First, Check the Rust compiler version.

C:\>rustc --version
rustc 1.50.0 (5631f1c2d 2022-02-02)

You need to run the below command in the terminal.

rustup update
rustup update stable

Next, you can check the upgraded version using the below command.

C:\Users\Kiran>rustc --version
rustc 1.60.0 (7737e0b5c 2022-04-04)

It upgrades the rustc compiler and cargo to the latest version.

For a reason, if cargo is not updated to the latest version, You can still run forcibly using --force

cargo install cargo --force