Editare

Set up your Rust development environment on Windows

Step 1: Install the MSVC C++ Build Tools

Rust on Windows requires Microsoft's C++ build tools as a prerequisite. If you already have Visual Studio installed with the Desktop development with C++ workload, you can skip this step.

Otherwise, install the Microsoft C++ Build Tools and select the Desktop development with C++ workload.

Note

Use of the Microsoft C++ Build Tools requires a valid Visual Studio license (Community, Pro, or Enterprise). The Community edition is free for students, open-source contributors, and individuals.

Step 2: Install Rust

Important

Smart App Control runs only code that it predicts to be safe or that is signed by a certificate authority in the Microsoft Trusted Root Program. The Rust toolchain for Windows is not currently Authenticode signed, so on a device that has Smart App Control turned on, the installed cargo and rustc binaries, and binaries produced by your build scripts, can be blocked from running. The block surfaces as Application Control policy has blocked this file. and is recorded in the Applications and Services Logs > Microsoft > Windows > CodeIntegrity > Operational event log; there's no other in-product signal, so the failure can look like a broken installer. Developer Mode and locally trusted certificates aren't exemptions. To check whether Smart App Control is on, go to Settings > Privacy & security > Windows Security > App & browser control > Smart App Control settings. For background, see Smart App Control overview and Code signing options for Windows app developers.

The official Rust installer, rustup, handles everything — the compiler, Cargo, and future updates.

winget install Rustlang.Rustup

After installation, open a new terminal and verify your setup:

cargo --version
rustc --version

Tip

To keep Rust up to date, run rustup update periodically.

Step 3: Install Visual Studio Code and the Rust extension

  1. Download and install Visual Studio Code.
  2. Install the rust-analyzer extension from the VS Code Marketplace. This adds code completion, inline errors, go-to-definition, and debugging support.

Next steps