This is how to install Rust on windows with Visual Studio Code and optionally MSYS2 MinGW

You can Instal Rust without installing "Microsoft C++ Build Tools". You can also use Rust with the gcc or clang tools from the MSYS2 suite.

I didn't want to install Rust on Windows with the required "Microsoft C++ Build Tools" because this would need too much disk space. To get Microsoft C++ Build Tools on Windows you need to download a full Windows SDK which is very large (I think more than 4GB).

You can run and debug Rust programs without installing MSYS2.

If you want to use the gcc or clang compilers that are included in MSYS2 (you will need to install them in a separate step from the MSYS2 installation, using the version of the pacman package manager from MSYS2), then you can install MSYS2.

(MSYS2 also allows you build very easily, C++ programs inside Visual Studio Code with the C++ extensions installed, using the gcc or clang compilers).

The MSYS2 installation version needs 1.61 GB for MSYS2 ( The tools installed using mingw-w64-x86_64-toolchain occupy 1083.49 MiB of disk space out of the 1.61 for the total MSYS2 suite).

Rust installs about 1.46 GB of files - mostly in the "C:\Users\user\.rustup" folder when using the parameter "x86_64-pc-windows-gnu" (for a MSYS MinGW install).

Rust takes up 900 MB after installation, when using "x86_64-pc-windows-msvc" (for a "Microsoft C++ Build Tools" install).

For a better Rust experience inside VS Code it is recommended to install the rust-analyzer extension Online from the VS Code Marketplace, or instead of it, the Rust plugin from [Link1] below, at the bottom of the post.

All you have to do is:

  • Install Visual Studio Code
  • (Optional - Install MSYS2)
  • Install Rust
  • Install Pyton if you don't have it
  • Add the required folders to the PATH variable
  • Install rust-analyzer and CodellDB extensions inside VS Code

At the end of this guide you should be able to run and debug rust programs inside Visual Studio Code.

MSYS2 is optional, you can install it if you want to use the gcc or clang from the suite - after creating the cargo config file, the cargo build and cargo run commands will use msys64\mingw64\bin\clang++.exe (by default if both compilers are installed, or ..\msys64\mingw64\bin\gcc.exe if you set it up to do this).


Just follow the installation from Part 1 - below. (This part is just for reference - it lists the files and folders required for setup and how I chose the installation directories - )

I installed the programs inside these folders:

   D:\Applications\msys64
   D:\Applications\VSCode

rustup-init.exe installs the .cargo folder in the default location:

C:\Users\user\.cargo


(  The settings files for VS Code are created and edited inside the Visual Studio Code editor, you don't need to open the files form windows explorer:
   C:\Users\user\AppData\Roaming\Code\User\settings.json
   C:\Users\user\AppData\Roaming\Code\User\keybindings.json
)

Part 1 - Installation Steps with Details:

I will use the code needed to run the installation programs inside "quotes" - remove the quotes when you run the commands. For example: "pacman -Syu" - remove the quotes and just run pacman -Syu .

Change the paths in the tutorial, for your installations.

The programs needed are VS Code, MSYS2 (MSYS2 has files/tools from MinGW), the rust-analyzer extension for VS Code for code completion and the CodeLLDB extension (with the author Vadim Chugunov) for debugging.

Make sure to have the Windows Firewall setup to allow connections out for MSYS2, VS Code, the Rust installer - rustup-init.exe (maybe rustup later on - during this tutorial you don't need it) and D:\Applications\msys64\usr\bin\pacman.exe. This will allow the programs to download necessary files for components or plugins.

a) Download Visual Studio Code portable version for Windows from filehorse.com and extract the files (or install it any way you like). Open VS Code and disable the 2 telemetry options from the settings:

Click on Edit > Preferences > Settings, type telemetry in the input box and disble the 2 telemetry options (or press the key combo: Ctrl + Shift + P, type open settings and press Enter to open the 'settings.json' file) this will put inside the "settings.json" file this code, between the main open and close curly braces:

"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false

Good fonts to use inside VS Code are: Fira Code, Consolas, DejaVu Sans Mono, Droid Sans Mono Slashed, Inconsolata-g, Bitstream Vera Sans Mono , Lucida Console, maybe Menlo Regular (was used in MacOS), Meslo LG DZ.

Fonts like 'Fira Code' have font ligatures present inside the font. 'Fire Code' doesn't have traditional font ligatures for example ft is not connected, but has ligatures specific for coding, for example the look of these character combinations are changed and usually look better with ligatures enabled: fl , -> , <= , >= . See the image below the post for an image with font ligatures on vs off. To enable font ligatures, open the Preferences for Visual Studio Code, search for ligatures in the search box, and enable the setting: 'Editor:Font Ligatures' .

You can change the default user data directory from:

"C:\Users\user\AppData\Roaming\Code" to your desired location, e.g. :

"D:\Applications\VSCode\UserData\Code"

by creating a shortcut for VSCode with the parameter --user-data-dir, that you'll use to launch VS Code.

To do this create a shortcut for VSCode with the setting for Target: D:\Applications\VSCode\Code.exe --user-data-dir "D:\Applications\VSCode\UserData\Code"

b) This step is Optional, follow it only if you want to use gcc or clang from MSYS2:

You can run Rust programs and compile them in Visual Studio Code without installing MSYS2. Install MSYS2 only if you want to use its gcc or clang compiler.

Optional - Install MSYS2 - this is about 1.61 GB. Download MSYS2 and follow the installation instructions - I will mention the most important steps:

  • Install MSYS2 and keep the checkbox selected: "run MSYS2 64bit" at the end of the installation.

  • Run pacman -Syu in the console that appears after the installation. This is the MSYS2 shell.

!!! For the next step, be careful an choose the right shortcut Don't choose the MinGW one, so

  • run the shortcut named "MSYS2 MSYS" from Start menu (it is "D:\Applications\msys64\msys2_shell.cmd -msys"). This is the MSYS2 shell. Inside the shell run pacman -Su .

    The next step is to download the programs needed to build the programs written in Rust, for the Windows Platform:

  • From the start menu run "MSYS2 MinGW 64-bit" (it is "D:\Applications\msys64\msys2_shell.cmd -mingw64"). This is for MinGW and it has a different parameter from the shortcut used above.

  • Run pacman -S mingw-w64-x86_64-toolchain.

Press Enter, Enter and type 'y' during the installation process.

( The guide on the msys2.org page said to also install some packages using the option '--needed base-devel' by runnig the command "pacman -S --needed base-devel mingw-w64-x86_64-toolchain", but I don't think they are needed here.

If you want, you can install single tools and their dependencies from the list of tools installed by the command "--needed base-devel", by selecting their corresponding number during the installation, for example you can just install make and not the rest of the tools present in the "--needed base-devel" package.

The simple rust "hello world" program that I wrote in rust using VS Code and the rustc and cargo tools/programs ran well without installing the "--needed base-devel" files.

The --needed base-devel files are not needed to run and debug simple Rust programs,but you can install them if you want.

To use the gcc or clang linker and compiler from MSYS2 you have to create the C:\Users\user\.cargo\config file:

To make the cargo use clang++.exe , add these lines to the C:\Users\user\.cargo\config file:

[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\clang++.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\llvm-ar.exe"

If you want to change the linker to gcc, create the C:\Users\user\.cargo\config file that contains the lines:

[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\gcc.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\ar.exe"

(clang++.exe is the same file as clang.exe from the same directory.) I got everything installed and running well - I could run the programs and debug them using gcc or clang. )

c) Install Rust for Windows Download the installer: rustup-init.exe from rust-lang.org

The browser should recognize that you ar using Windows and give you the link to "DOWNLOAD RUSTUP-INIT.EXE (64-BIT)" , that is: [...]static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe

Run rustup-init.exe . It is better to launch a console with cmd.exe and launch rustup-init.exe from there.
  • choose "Continue? (y/N)" by typing y and hitting the Enter key.

  • choose "2) Customize installation" using the keyboard.

  • paste or type the option: x86_64-pc-windows-gnu .

  • Press enter for the rest of the options.

  • Finally type "1" as input in the console, then press Enter, to choose the option "1 to proceed" with the Current installation Options.

There might be problems if you had rustup already installed. If you already have rustup installed follow the indications on the guide at Source 1 Link at the bottom of the page with the step-by-step-instruction-to-install-rust-and-cargo-for-mingw-with-msys2 :

This is a quote from that post:

"Note: If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run rustup toolchain install stable-x86_64-pc-windows-gnu if you already have the MSVC-based toolchain. Then run rustup default stable-x86_64-pc-windows-gnu to set the GNU-based toolchain as the default."

d) Add the folders to the PATH

Add the folders that have useful programs from rust and msys2 to the Windows system PATH variable:

Adding the folders to the system PATH variable will allow VS Conde console, which defaults to PowerShell (you can change it to Command Prompt or other shell if you want), to recognize the commands: cargo, rustc, etc. This will make running and debugging rust programs in VS Code with the rust-analyzer and CodeLLDB extensions easy because you don't have to configure anything else.

To add the folders to the PATH use the System Properties window:

  • Right click on "My Computer" and select "properties"
  • Click on Advanced System Settings
  • In the Advanced tab, click on "Environment Variables"
  • under 'User variables for user' click on the PATH Variable and add the locations of your cargo\bin folder and mingw64\bin folder, (plus \msys64):
;C:\Users\user\.cargo\bin;D:\Applications\msys64;D:\Applications\msys64\mingw64\bin

This will add the folders "C:\Users\user\.cargo\bin", "D:\Applications\msys64", "D:\Applications\msys64\mingw64\bin" to the PATH variable. (stackoverflow is bad at formatting \. backslash followed by a dot - you have to use another backslash as an escape character)

To test that the PATH variable is updated open a NEW Command Prompt or PowerShell window, and in this window run cargo --version or gcc --version (if you installed MSYS2 and gcc.exe) or rustc --version inside a 'Command Prompt' window and inside a PowerShell Window. If the commands are not found, restart your computer so that Windows can update the PATH variable. For me the change worked without having to restart, I just had to open a new shell window.

e) Install the Rust extensions for VS Code

rust-analyzer and CodeLLDB require Python to be installed.

Install Python 3.6.3, for example, and select to add it to the path during installation.

From the VS Code Marketplace install the needed extensions. Open VS Code, click on the Extensions button on the right toolbar, and search and install the extensions:

  • rust-analyzer - (publisher: matklad) ;
  • CodeLLDB (publisher: Vadim Chugunov);

( I didn't have to do this next step so you shouldn't either - if rust-analyzer doesn't load/run properly, you may need to install the rust source code. Using the 'Command Prompt' run: rustup component add rust-src to install the rust Source Code. I didn't have to install it, the rust-analyzer worked well [ by the way, the VS Code could connect to the internet during testing].

)

[While running Visual Studio Code you may get a message telling you to install .Net Framework 4.5.2. Download and install the Offline version if the online version fails to install. (On Windows 7 without some updates, you may have to download and install the certificate: MicRooCerAut2011_2011_03_22.crt, and install some windows updates: Windows6.1-KB2533623-x64, windows6.1-kb2813430-x64, and maybe Windows6.1-KB4019990-x64 ) ]

Part 2 - Running and Debugging Rust programs with VS Code

Running and compiling in Rust with VS Code and Msys2:

After adding the folders to the PATH and installing the extensions, you basically need to run:

  1. cargo init
  2. cargo run - to run the program.
  3. press the F5 key, or click the debug button to debug the code.

First you need to:

  • Create a folder for your Rust app.
  • Open the folder inside VS Code.
  • Press Ctrl+{`} to open the terminal panel. The default shell will be 'PowerShell'.

You can select the 'Command prompt' shell from the Terminal pane using the down arrow on the left, that is near the plus button and x button. Or you can set VS Code to use 'Command Prompt' as the default shell by adding the lines to the 'settings.json' file - the main Visual Studio Settings file.

"terminal.integrated.defaultProfile.windows": "Command Prompt",

You can use PowerShell or 'Command Prompt', they both work fine.

  • Run cargo init inside the terminal to create the project files.

  • Edit the main.rs file if you want. It is located inside 'app folder'\src\main.rs

  • Run cargo run inside the terminal

If you have rust-analyzer installed, the extension puts 2 buttons as popups on top of the main() function. They are named 'Run' and 'Debug' and if clicked they do what their names say.

To debug, put a breakpoint inside your main.rs file and hit F5 (the menu entry Run > Start Debugging) or click the Debug button on top of the main() function placed there by the rust-analyzer extension if you have it installed.

If you click the debug button you don't have to create a launch.json config file. If you hit the F5 key or click the menu entry Run > Start Debugging, a launch.json file will be added to your folder.

Just click Yes in the message box to auto generate the launch.json file. Then hit the F5 key again to start debugging. Now you can step through your code during the debugging process.


Link 1: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust

Link to Font Ligatures example - Image for the font 'Fira Code':

Image Link: Coding font with font ligatures

Answer from pclinux on Stack Overflow
🌐
Rust Programming Language
rust-lang.org › tools › install
Install Rust - Rust Programming Language
It looks like you’re running Windows. To start using Rust, download the installer, then run the program and follow the onscreen instructions. You may need to install the Visual Studio C++ Build tools when prompted to do so.
Discussions

gcc - Rust installation on Windows - Stack Overflow
I was trying to get Rust to work on my Windows box. I followed the instructions, however when I tried hello world program, it spits the below. It looks like it has not been able to link up to gcc..... More on stackoverflow.com
🌐 stackoverflow.com
installing Rust on Windows without Microsoft C++ Build Tools
Problem you are trying to solve I want to install Rust on Windows without using the Microsoft C++ Build Tools, because I prefer not to install gigabytes of license-restricted software just to be ab... More on github.com
🌐 github.com
12
May 17, 2023
How to install Rust via CLI on Windows? - Stack Overflow
I am trying to install Rust via the command line on a Windows VM (https://github.com/sansyrox/robyn/pull/263). The script on the main Rust installation website only supports *nix os. What are the More on stackoverflow.com
🌐 stackoverflow.com
How to install Rust on Win11?
C:\Users\Guru\Downloads rustup-init.exe Rust Visual C++ prerequisites Rust requires a linker and Windows API libraries but they don't seem to be available. [I HAVE INSTALLED SOMETHING (VCRUNTIME140.DLL), SO NOW RUST EXECUTABLES CAN START] These components can be acquired through a Visual Studio ... More on users.rust-lang.org
🌐 users.rust-lang.org
4
0
March 2, 2025
🌐
The Rust Programming Language
doc.rust-lang.org › book › ch01-01-installation.html
Installation - The Rust Programming Language
... Linux users should generally install GCC or Clang, according to their distribution’s documentation. For example, if you use Ubuntu, you can install the build-essential package. On Windows, go to https://www.rust-lang.org/tools/install and follow the instructions for installing Rust.
🌐
Microsoft Learn
learn.microsoft.com › en-us › windows › dev-environment › rust › setup
Set up your dev environment on Windows for Rust | Microsoft Learn
1 month ago - Download and run the installer from rustup.rs. Accept the defaults to install the MSVC toolchain, which is recommended for Windows development.
🌐
Rust
rustup.rs
rustup.rs - The Rust toolchain installer
If you are running Windows 32-bit, download and run rustup‑init.exe then follow the onscreen instructions. To install Rust, if you are running Unix, run the following in your terminal, then follow the onscreen instructions.
Top answer
1 of 4
13

This is how to install Rust on windows with Visual Studio Code and optionally MSYS2 MinGW

You can Instal Rust without installing "Microsoft C++ Build Tools". You can also use Rust with the gcc or clang tools from the MSYS2 suite.

I didn't want to install Rust on Windows with the required "Microsoft C++ Build Tools" because this would need too much disk space. To get Microsoft C++ Build Tools on Windows you need to download a full Windows SDK which is very large (I think more than 4GB).

You can run and debug Rust programs without installing MSYS2.

If you want to use the gcc or clang compilers that are included in MSYS2 (you will need to install them in a separate step from the MSYS2 installation, using the version of the pacman package manager from MSYS2), then you can install MSYS2.

(MSYS2 also allows you build very easily, C++ programs inside Visual Studio Code with the C++ extensions installed, using the gcc or clang compilers).

The MSYS2 installation version needs 1.61 GB for MSYS2 ( The tools installed using mingw-w64-x86_64-toolchain occupy 1083.49 MiB of disk space out of the 1.61 for the total MSYS2 suite).

Rust installs about 1.46 GB of files - mostly in the "C:\Users\user\.rustup" folder when using the parameter "x86_64-pc-windows-gnu" (for a MSYS MinGW install).

Rust takes up 900 MB after installation, when using "x86_64-pc-windows-msvc" (for a "Microsoft C++ Build Tools" install).

For a better Rust experience inside VS Code it is recommended to install the rust-analyzer extension Online from the VS Code Marketplace, or instead of it, the Rust plugin from [Link1] below, at the bottom of the post.

All you have to do is:

  • Install Visual Studio Code
  • (Optional - Install MSYS2)
  • Install Rust
  • Install Pyton if you don't have it
  • Add the required folders to the PATH variable
  • Install rust-analyzer and CodellDB extensions inside VS Code

At the end of this guide you should be able to run and debug rust programs inside Visual Studio Code.

MSYS2 is optional, you can install it if you want to use the gcc or clang from the suite - after creating the cargo config file, the cargo build and cargo run commands will use msys64\mingw64\bin\clang++.exe (by default if both compilers are installed, or ..\msys64\mingw64\bin\gcc.exe if you set it up to do this).


Just follow the installation from Part 1 - below. (This part is just for reference - it lists the files and folders required for setup and how I chose the installation directories - )

I installed the programs inside these folders:

   D:\Applications\msys64
   D:\Applications\VSCode

rustup-init.exe installs the .cargo folder in the default location:

C:\Users\user\.cargo


(  The settings files for VS Code are created and edited inside the Visual Studio Code editor, you don't need to open the files form windows explorer:
   C:\Users\user\AppData\Roaming\Code\User\settings.json
   C:\Users\user\AppData\Roaming\Code\User\keybindings.json
)

Part 1 - Installation Steps with Details:

I will use the code needed to run the installation programs inside "quotes" - remove the quotes when you run the commands. For example: "pacman -Syu" - remove the quotes and just run pacman -Syu .

Change the paths in the tutorial, for your installations.

The programs needed are VS Code, MSYS2 (MSYS2 has files/tools from MinGW), the rust-analyzer extension for VS Code for code completion and the CodeLLDB extension (with the author Vadim Chugunov) for debugging.

Make sure to have the Windows Firewall setup to allow connections out for MSYS2, VS Code, the Rust installer - rustup-init.exe (maybe rustup later on - during this tutorial you don't need it) and D:\Applications\msys64\usr\bin\pacman.exe. This will allow the programs to download necessary files for components or plugins.

a) Download Visual Studio Code portable version for Windows from filehorse.com and extract the files (or install it any way you like). Open VS Code and disable the 2 telemetry options from the settings:

Click on Edit > Preferences > Settings, type telemetry in the input box and disble the 2 telemetry options (or press the key combo: Ctrl + Shift + P, type open settings and press Enter to open the 'settings.json' file) this will put inside the "settings.json" file this code, between the main open and close curly braces:

"telemetry.enableCrashReporter": false,
"telemetry.enableTelemetry": false

Good fonts to use inside VS Code are: Fira Code, Consolas, DejaVu Sans Mono, Droid Sans Mono Slashed, Inconsolata-g, Bitstream Vera Sans Mono , Lucida Console, maybe Menlo Regular (was used in MacOS), Meslo LG DZ.

Fonts like 'Fira Code' have font ligatures present inside the font. 'Fire Code' doesn't have traditional font ligatures for example ft is not connected, but has ligatures specific for coding, for example the look of these character combinations are changed and usually look better with ligatures enabled: fl , -> , <= , >= . See the image below the post for an image with font ligatures on vs off. To enable font ligatures, open the Preferences for Visual Studio Code, search for ligatures in the search box, and enable the setting: 'Editor:Font Ligatures' .

You can change the default user data directory from:

"C:\Users\user\AppData\Roaming\Code" to your desired location, e.g. :

"D:\Applications\VSCode\UserData\Code"

by creating a shortcut for VSCode with the parameter --user-data-dir, that you'll use to launch VS Code.

To do this create a shortcut for VSCode with the setting for Target: D:\Applications\VSCode\Code.exe --user-data-dir "D:\Applications\VSCode\UserData\Code"

b) This step is Optional, follow it only if you want to use gcc or clang from MSYS2:

You can run Rust programs and compile them in Visual Studio Code without installing MSYS2. Install MSYS2 only if you want to use its gcc or clang compiler.

Optional - Install MSYS2 - this is about 1.61 GB. Download MSYS2 and follow the installation instructions - I will mention the most important steps:

  • Install MSYS2 and keep the checkbox selected: "run MSYS2 64bit" at the end of the installation.

  • Run pacman -Syu in the console that appears after the installation. This is the MSYS2 shell.

!!! For the next step, be careful an choose the right shortcut Don't choose the MinGW one, so

  • run the shortcut named "MSYS2 MSYS" from Start menu (it is "D:\Applications\msys64\msys2_shell.cmd -msys"). This is the MSYS2 shell. Inside the shell run pacman -Su .

    The next step is to download the programs needed to build the programs written in Rust, for the Windows Platform:

  • From the start menu run "MSYS2 MinGW 64-bit" (it is "D:\Applications\msys64\msys2_shell.cmd -mingw64"). This is for MinGW and it has a different parameter from the shortcut used above.

  • Run pacman -S mingw-w64-x86_64-toolchain.

Press Enter, Enter and type 'y' during the installation process.

( The guide on the msys2.org page said to also install some packages using the option '--needed base-devel' by runnig the command "pacman -S --needed base-devel mingw-w64-x86_64-toolchain", but I don't think they are needed here.

If you want, you can install single tools and their dependencies from the list of tools installed by the command "--needed base-devel", by selecting their corresponding number during the installation, for example you can just install make and not the rest of the tools present in the "--needed base-devel" package.

The simple rust "hello world" program that I wrote in rust using VS Code and the rustc and cargo tools/programs ran well without installing the "--needed base-devel" files.

The --needed base-devel files are not needed to run and debug simple Rust programs,but you can install them if you want.

To use the gcc or clang linker and compiler from MSYS2 you have to create the C:\Users\user\.cargo\config file:

To make the cargo use clang++.exe , add these lines to the C:\Users\user\.cargo\config file:

[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\clang++.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\llvm-ar.exe"

If you want to change the linker to gcc, create the C:\Users\user\.cargo\config file that contains the lines:

[target.x86_64-pc-windows-gnu]
linker = "D:\\Applications\\msys64\\mingw64\\bin\\gcc.exe"
ar = "D:\\Applications\\msys64\\mingw64\\bin\\ar.exe"

(clang++.exe is the same file as clang.exe from the same directory.) I got everything installed and running well - I could run the programs and debug them using gcc or clang. )

c) Install Rust for Windows Download the installer: rustup-init.exe from rust-lang.org

The browser should recognize that you ar using Windows and give you the link to "DOWNLOAD RUSTUP-INIT.EXE (64-BIT)" , that is: [...]static.rust-lang.org/rustup/dist/x86_64-pc-windows-msvc/rustup-init.exe

Run rustup-init.exe . It is better to launch a console with cmd.exe and launch rustup-init.exe from there.
  • choose "Continue? (y/N)" by typing y and hitting the Enter key.

  • choose "2) Customize installation" using the keyboard.

  • paste or type the option: x86_64-pc-windows-gnu .

  • Press enter for the rest of the options.

  • Finally type "1" as input in the console, then press Enter, to choose the option "1 to proceed" with the Current installation Options.

There might be problems if you had rustup already installed. If you already have rustup installed follow the indications on the guide at Source 1 Link at the bottom of the page with the step-by-step-instruction-to-install-rust-and-cargo-for-mingw-with-msys2 :

This is a quote from that post:

"Note: If rustup is already installed, then rerunning rustup-init won't actually install the requested toolchain. Instead, run rustup toolchain install stable-x86_64-pc-windows-gnu if you already have the MSVC-based toolchain. Then run rustup default stable-x86_64-pc-windows-gnu to set the GNU-based toolchain as the default."

d) Add the folders to the PATH

Add the folders that have useful programs from rust and msys2 to the Windows system PATH variable:

Adding the folders to the system PATH variable will allow VS Conde console, which defaults to PowerShell (you can change it to Command Prompt or other shell if you want), to recognize the commands: cargo, rustc, etc. This will make running and debugging rust programs in VS Code with the rust-analyzer and CodeLLDB extensions easy because you don't have to configure anything else.

To add the folders to the PATH use the System Properties window:

  • Right click on "My Computer" and select "properties"
  • Click on Advanced System Settings
  • In the Advanced tab, click on "Environment Variables"
  • under 'User variables for user' click on the PATH Variable and add the locations of your cargo\bin folder and mingw64\bin folder, (plus \msys64):
;C:\Users\user\.cargo\bin;D:\Applications\msys64;D:\Applications\msys64\mingw64\bin

This will add the folders "C:\Users\user\.cargo\bin", "D:\Applications\msys64", "D:\Applications\msys64\mingw64\bin" to the PATH variable. (stackoverflow is bad at formatting \. backslash followed by a dot - you have to use another backslash as an escape character)

To test that the PATH variable is updated open a NEW Command Prompt or PowerShell window, and in this window run cargo --version or gcc --version (if you installed MSYS2 and gcc.exe) or rustc --version inside a 'Command Prompt' window and inside a PowerShell Window. If the commands are not found, restart your computer so that Windows can update the PATH variable. For me the change worked without having to restart, I just had to open a new shell window.

e) Install the Rust extensions for VS Code

rust-analyzer and CodeLLDB require Python to be installed.

Install Python 3.6.3, for example, and select to add it to the path during installation.

From the VS Code Marketplace install the needed extensions. Open VS Code, click on the Extensions button on the right toolbar, and search and install the extensions:

  • rust-analyzer - (publisher: matklad) ;
  • CodeLLDB (publisher: Vadim Chugunov);

( I didn't have to do this next step so you shouldn't either - if rust-analyzer doesn't load/run properly, you may need to install the rust source code. Using the 'Command Prompt' run: rustup component add rust-src to install the rust Source Code. I didn't have to install it, the rust-analyzer worked well [ by the way, the VS Code could connect to the internet during testing].

)

[While running Visual Studio Code you may get a message telling you to install .Net Framework 4.5.2. Download and install the Offline version if the online version fails to install. (On Windows 7 without some updates, you may have to download and install the certificate: MicRooCerAut2011_2011_03_22.crt, and install some windows updates: Windows6.1-KB2533623-x64, windows6.1-kb2813430-x64, and maybe Windows6.1-KB4019990-x64 ) ]

Part 2 - Running and Debugging Rust programs with VS Code

Running and compiling in Rust with VS Code and Msys2:

After adding the folders to the PATH and installing the extensions, you basically need to run:

  1. cargo init
  2. cargo run - to run the program.
  3. press the F5 key, or click the debug button to debug the code.

First you need to:

  • Create a folder for your Rust app.
  • Open the folder inside VS Code.
  • Press Ctrl+{`} to open the terminal panel. The default shell will be 'PowerShell'.

You can select the 'Command prompt' shell from the Terminal pane using the down arrow on the left, that is near the plus button and x button. Or you can set VS Code to use 'Command Prompt' as the default shell by adding the lines to the 'settings.json' file - the main Visual Studio Settings file.

"terminal.integrated.defaultProfile.windows": "Command Prompt",

You can use PowerShell or 'Command Prompt', they both work fine.

  • Run cargo init inside the terminal to create the project files.

  • Edit the main.rs file if you want. It is located inside 'app folder'\src\main.rs

  • Run cargo run inside the terminal

If you have rust-analyzer installed, the extension puts 2 buttons as popups on top of the main() function. They are named 'Run' and 'Debug' and if clicked they do what their names say.

To debug, put a breakpoint inside your main.rs file and hit F5 (the menu entry Run > Start Debugging) or click the Debug button on top of the main() function placed there by the rust-analyzer extension if you have it installed.

If you click the debug button you don't have to create a launch.json config file. If you hit the F5 key or click the menu entry Run > Start Debugging, a launch.json file will be added to your folder.

Just click Yes in the message box to auto generate the launch.json file. Then hit the F5 key again to start debugging. Now you can step through your code during the debugging process.


Link 1: https://marketplace.visualstudio.com/items?itemName=rust-lang.rust

Link to Font Ligatures example - Image for the font 'Fira Code':

Image Link: Coding font with font ligatures

2 of 4
4

This question is old, but in the mean time a lot has changed.

The easiest way to install on Windows is to go to the Rust installation page and download and run rustup-init.exe. It installs rustc, rustup and similar tools. It just works.

🌐
GeeksforGeeks
geeksforgeeks.org › rust › how-to-install-rust-on-windows-and-linux-operating-system
How to Install Rust on Windows and Linux Operating System? - GeeksforGeeks
July 23, 2025 - Step 1: First, go to the Rust official website and download the Rust installer. Step 2: After downloading click on the setup which is downloaded. It will take you to the command prompt as shown below.
Find elsewhere
🌐
Peter Girnus
petergirnus.com › blog › how-to-install-rust-on-windows
How to Install Rust on Windows from the Terminal — Peter Girnus
October 16, 2023 - Easily Install Rust on Windows 10 or Windows 11. I will show you how to install Rust without an installer using the Windows Package Manager (winget) to install Rust with rustup, the Rust toolchain as well as the necessary dependencies such as Visual Studio build tools, Desktop development with C++ tool set.
🌐
URI
homepage.cs.uri.edu › faculty › hamel › courses › home › csc301 › rust-installation-windows.pdf pdf
Rust + Cargo Install Guide: Step 1
Step 2) Gp to​ ​https://www.rust-lang.org/tools/install​ ​It will auto detect what operating system
🌐
Rust
rust-lang.github.io › rustup › installation › windows-msvc.html
MSVC prerequisites - The rustup book
winget install --source winget --id Microsoft.WindowsSDK.10.0.26100 · Download Visual Studio. Rust supports Visual Studio 2017 and later but it is recommended that you use the latest version (currently 2022) for new projects. You can opt to download only the Build Tools for Visual Studio, which does not include the IDE.
🌐
UltaHost
ultahost.com › knowledge-base › install-rust-on-windows
How to Install Rust on Windows | Ultahost Knowledge Base
June 28, 2024 - Visit the official Rust installation page to download the Rust installer. On this page, you’ll find two types of installers: 32-bit and 64-bit. It’s essential to choose the correct installer for your system architecture: Once you’ve selected ...
🌐
Rust Programming Language
rust-lang.org › learn › get-started
Getting started - Rust Programming Language
It looks like you’re running Windows. To start using Rust, download the installer, then run the program and follow the onscreen instructions. You may need to install the Visual Studio C++ Build tools when prompted to do so.
🌐
DEV Community
dev.to › stellaacharoiro › how-to-install-rust-a-complete-guide-1fm0
How to Install Rust: A Complete Guide - DEV Community
April 4, 2025 - The following guide will walk you through the process of installing Rust on different operating systems.
🌐
Rust
rust-lang.github.io › rustup › installation › windows.html
Windows - The rustup book
Just install it with rustup toolchain install: ... You don’t need to switch toolchains to support all windows targets though; a single toolchain supports all four x86 windows targets:
🌐
GitHub
github.com › rust-lang › rustup › issues › 3358
installing Rust on Windows without Microsoft C++ Build Tools · Issue #3358 · rust-lang/rustup
May 17, 2023 - Problem you are trying to solve I want to install Rust on Windows without using the Microsoft C++ Build Tools, because I prefer not to install gigabytes of license-restricted software just to be ab...
Published   May 17, 2023
Author   garretwilson
🌐
alpharithms
alpharithms.com › home › tutorials › walkthrough: installing rust on windows
Walkthrough: Installing Rust on Windows - αlphαrithms
January 11, 2022 - It offers the same speed and low-level access as C-based languages but has a few more safety precautions. Table of Contents show 1 Step 1: Download Rust Setup Package 2 Step 2: Run Rustup-init.exe 2.1 Step 2.b: Install Visual ...
Top answer
1 of 2
3

Install it with scoop for easier package management on your system with a single command:

GNU toolchain

scoop install rustup-gnu
rustup toolchain install stable-x86_64-pc-windows-gnu
rustup default stable-x86_64-pc-windows-gnu

or

scoop install rustup for MSVC toolchain

Then you can update rustup or uninstall it whenever you want with:

scoop upgrade rustup

scoop uninstall rustup.

2 of 2
2

Follow directions in Other ways to install rustup. Download rustup-init.exe based on the target toolchain of your choice:

  • 64-bit MSVC: x86_64-pc-windows-msvc/rustup-init.exe
  • 64-bit GNU: x86_64-pc-windows-gnu/rustup-init.exe
  • 32-bit MSVC: i686-pc-windows-msvc/rustup-init.exe
  • 32-bit GNU: i686-pc-windows-gnu/rustup-init.exe

You can use --help to see what options there are to configure the installation:

> .\rustup-init.exe --help
rustup-init 1.24.3 (ce5817a94 2021-05-31)
The installer for rustup

USAGE:
    rustup-init.exe [FLAGS] [OPTIONS]

FLAGS:
    -v, --verbose                        Enable verbose output
    -q, --quiet                          Disable progress output
    -y                                   Disable confirmation prompt.
        --no-update-default-toolchain    Don't update any existing default toolchain after install
        --no-modify-path                 Don't configure the PATH environment variable
    -h, --help                           Prints help information
    -V, --version                        Prints version information

OPTIONS:
        --default-host <default-host>              Choose a default host triple
        --default-toolchain <default-toolchain>    Choose a default toolchain to install
        --profile <profile>                         [default: default]  [possible values: minimal, default, complete]
    -c, --component <components>...                Component name to also install
    -t, --target <targets>...                      Target name to also install

The basic -y should work for you; it will install rustup and the default toolchain. You can of course use wget to download the installer within a script.

> wget https://static.rust-lang.org/rustup/dist/x86_64-pc-windows-gnu/rustup-init.exe
> .\rustup-init.exe -vy

Note, the MSVC toolchain will require you to install the Visual C++ Build Tools to function. I'm unsure how to install those in a CLI only environment. Hopefully the .exe for that functions similarly.

See also:

  • What are the differences between the GNU and MSVC Rust toolchain?
  • How to install Visual C++ Build tools?