Once you understand the study roadmap from Session 1, it is time to install Rust and see it working. Session 2 covers installing the toolchain with rustup and using cargo to scaffold, build, and run a project. Everything happens on the CLI, so learning the command flow early prevents later friction.
New terms in this post
- rustup: The official installer that manages the Rust compiler and related tools.
- toolchain: A named bundle like
stable,beta, ornightlythat shipsrustc,cargo, and the standard library together. - Cargo manifest: The
Cargo.tomlfile at the project root that stores the package name, version, and dependencies.
Core ideas
- Rust installation is a single
rustupscript and includes thestabletoolchain,cargo, andrustcby default. - Project creation, build, run, and test flows all go through
cargo;cargo newscaffolds the project for you. - Once you understand
Cargo.tomlandsrc/main.rs, you know exactly where to place code in any tutorial sample. cargo runbuilds and executes,cargo buildonly builds, andcargo checkcompiles quickly without generating a binary.
Code along
1. Install rustup
This walkthrough uses macOS, but Windows and Linux follow nearly the same steps. When in doubt, refer to the official docs for your OS.
On macOS, you can think of two reasonable install paths:
- Official installer script: the path shown most often in Rust's official docs
- Homebrew + rustup: convenient if you already use Homebrew heavily
The important part is the same in both cases: let rustup manage the actual Rust toolchain. If you are just getting started, it is cleaner to avoid brew install rust and install only rustup.
If you want to use the official installer, run the script below in Terminal on macOS or Linux (PowerShell works similarly on Windows):
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
If you prefer Homebrew, this path also works:
brew install rustup
rustup default stable
This installs rustup with Homebrew, then lets rustup download and manage rustc and cargo. Unless you have a specific reason, skip brew install rust at the beginning. Mixing both can make PATH order and toolchain ownership harder to reason about.
When asked which toolchain to install, accept the default stable. After the installer finishes, open a new terminal and check versions.
rustc --version
cargo --version
2. Create the first project
Pick a practice folder and run cargo new hello-rust.
cargo new hello-rust
cd hello-rust
You will see a simple structure.
hello-rust/
├── Cargo.toml
└── src/
└── main.rs
Cargo.toml holds package metadata and dependency info, while src/main.rs contains the starter main function.
3. Build and run
From the project root, run the following commands in order.
cargo build
cargo run
cargo buildcreates a binary insidetarget/debug.cargo runbuilds when needed and immediately runs the binary.cargo checkskips binary generation and only validates that the code compiles.
Edit the code to feel the build loop.
fn main() {
let name = "Mathbong";
println!("안녕하세요, {}!", name);
}
Run cargo run again to see the new output.
4. Quick verification with cargo check
Use cargo check when you only need syntax and type feedback. It skips linking, so it completes faster.
cargo check
Why it matters
- Many learners get stuck when they paste code before understanding the install and build chain. Session 2 stabilizes the environment so later exercises go faster.
- Cargo is the standard build system, so a few commands take you from dependency management to testing and release builds.
- Tools like
cargo checkshorten the feedback loop while you experiment with ownership and type errors.
Practice in CodeSandbox
The sandbox below uses CodeSandbox's Rust starter. Move the main code into src/main.rs, then compare cargo check and cargo run so you can read the compiler feedback beside the final output.
💬 댓글
이 글에 대한 의견을 남겨주세요