Rust 01. Install Rust and Run Hello World
Summary
When you first start with Rust, the least confusing path is usually to install everything through the official tool, rustup, instead of trying to think in terms of the compiler alone. This post walks through the shortest beginner path on Windows with VS Code: install Rust, verify the toolchain, run Hello, world! with rustc, and then run the same idea through cargo.
The practical takeaway is simple: use rustup to install Rust, rustc for a quick single-file check, and cargo for real project work.
Document Information
- Written on: 2026-04-07
- Verification date: 2026-04-15
- Document type: tutorial
- Test environment: Windows PowerShell, VS Code,
rustup,rustc,cargo - Test version: rustc 1.94.0, cargo 1.94.0
- Source quality: only official documentation is used.
- Note: installer screens and installer UI can change over time. This post only covers the simplest local Windows path.
Problem Definition
At the beginning, Rust installation usually feels ambiguous in three places.
- It is not obvious whether “install Rust” means installing
rustcdirectly or installingrustup. - It is easy to confuse the roles of
rustcandcargo. - After installation, many beginners are not sure what they should run to confirm that the setup actually worked.
This post only covers the minimum path needed to reduce that confusion: install, verify, and run Hello, world!. It does not cover advanced installer flags, WSL, macOS/Linux, or toolchain override topics.
How to read this post: treat rustup as the entry point for installing and updating the toolchain, rustc as the compiler you can call directly, and cargo as the project workflow tool. At this stage, you do not need to memorize every option. The important part is knowing which tool to reach for in each situation.
Verified Facts
- The official Rust install page and the
rustupsite guide users through therustupinstallation path. Evidence: Install Rust, rustup.rs Meaning: “Installing Rust” here does not mean downloading only therustcexecutable. It means setting up the standard path for managing the Rust toolchain. - The Rust Book installation chapter describes verifying the installation with
rustc --version. Evidence: Installation Meaning: if this command prints a version, the terminal can find the Rust compiler and the basic PATH/toolchain connection is working. - The Rust Book separates the single-file
rustcflow from the project-orientedcargo new,cargo build, andcargo runflow. Evidence: Hello, World!, Hello, Cargo! Meaning:rustcandcargoare not competing tools.rustcis the compiler, whilecargowraps project creation, builds, runs, and dependency management. - The official VS Code Rust guide recommends
rust-analyzeras the editor extension. Evidence: Rust in Visual Studio Code Meaning:rust-analyzerdoes not install Rust. It helps the editor understand Rust code.
Directly Confirmed Results
1. Installation path and version check
- Direct result: after running the Windows
rustup-init.exeinstaller with the standard option, the installation could be verified in a new PowerShell window with the commands below.
rustc --version
cargo --version
- Observed result:
rustc 1.94.0 (4a4ef493e 2026-03-02)
cargo 1.94.0 (85eff7c80 2026-01-15)
-
How to read this: if both commands print versions, the installation and terminal setup are good enough for the rest of this beginner flow. The exact versions become the reference point for interpreting later outputs.
-
The reproducible path is:
- Open Rust install page or rustup.rs.
- Download and run
rustup-init.exefor Windows. - Choose
1) Proceed with standard installation. - Open a new PowerShell window and run the version-check commands above.
2. Smallest Hello World setup in VS Code
- Direct result: opening a folder in VS Code and saving the code below as
hello.rswas enough to start a single-file Rust check.
fn main() {
println!("Hello, world!");
}
- Direct result: if you plan to keep using VS Code, installing
rust-analyzermakes the editing experience noticeably better.
3. Building a single file with rustc
- Direct result: running the commands below in the folder containing
hello.rscreatedhello.exein the same directory.
rustc hello.rs
.\hello.exe
- Observed result:
Hello, world!
- How to read this:
rustc hello.rsis the shortest path from one source file to an executable. It is useful for a quick one-file syntax check, but it does not give you a project structure or dependency management.
4. Creating and running a project with cargo
- Direct result: the project-oriented flow was much easier to continue with. The commands below created and ran a new Rust project.
cargo new hello-rust
cd hello-rust
cargo run
- The generated
src/main.rsstarts like this.
fn main() {
println!("Hello, world!");
}
- Observed result:
Hello, world!
-
How to read this:
cargo runbuilds if needed and then runs the project. For beginners, it is the default command for repeatedly running a growing Rust project. -
Direct result: when using
cargo build, the executable was created undertarget\debug\hello-rust.exe.
Interpretation / Opinion
- Key decision at this stage: for beginners, the cleanest mental model is “Rust installation means installing the toolchain through
rustup.” - Decision rule: use
rustcfor a one-file syntax check, and usecargofor code you expect to keep changing or growing. - Recommended flow: the most natural beginner sequence is “verify installation -> run one
rustcexample -> move into acargo newproject.”
Limits and Exceptions
- This post is written for Windows PowerShell and VS Code. It does not cover macOS, Linux, WSL, or remote-container setups.
- The exact
rustup-init.exescreens and defaults can change over time. - The scope is limited to installation and the first successful run. Toolchain overrides, nightly, cross-compilation, and C++ toolchain edge cases are intentionally left out.
- VS Code is optional. Rust installation and
rustc/cargousage do not require a specific editor. - Remaining questions after this post include switching between toolchains, deciding when nightly is appropriate, and handling platform-specific native build tool issues. Those belong in an installation deep dive.
댓글남기기