Your country

Tools that support it use your country for local currency, number formats, units and paper size. Your choice is saved only in this browser.

Type a name or a two-letter code. Use the up and down arrow keys to move through the countries, Enter to choose one and Escape to close.

Rust (2024 edition)  Module 1 – Getting started: rustup, Cargo and compiler messages

Install Rust with rustup and pin a toolchain

Install Rust with rustup, check what it installed, choose stable, beta or nightly, and pin a project to one release, its components and targets.

  • Beginner
  • 15 minutes
  • Examples run with Rust 1.99.0 and Python 3.14.8
  • By MySmartCoPilot
Free lesson, Pro answers: 15 minutes
Free: the whole lesson. With a pass: the model answers to its 2 interview questions.

What you will learn

  • Install Rust with rustup and verify the rustc, cargo and rustup versions
  • Explain the stable, beta and nightly channels and when each is needed
  • Predict which toolchain rustup runs from a +toolchain argument, the environment, overrides, files and the default
  • Configure a project's toolchain, components and targets with rust-toolchain.toml

Before you start

What you’ll learn · Before you start

What you will learn

  • Install Rust with rustup and verify the rustc, cargo and rustup versions
  • Explain the stable, beta and nightly channels and when each is needed
  • Predict which toolchain rustup runs from a +toolchain argument, the environment, overrides, files and the default
  • Configure a project's toolchain, components and targets with rust-toolchain.toml

Before you start

On this page

The computer these sessions ran on has three Rust toolchain: One installed release of Rust's tools for one host: rustc, Cargo and the standard library, plus components such as rustfmt and Clippy. rustup names toolchains such as stable-aarch64-apple-darwin or 1.99.0-aarch64-apple-darwin. installed side by side, and the same command, rustc --version, answers 1.98.0 in one folder and 1.99.0 in another. Nothing is broken: rustup: The installer and manager of Rust toolchains. Its commands in ~/.cargo/bin, cargo and rustc among them, are proxies that choose a toolchain for each run and hand the command to that toolchain's own program., the installer, chooses a toolchain for every command, and one small file in a project decides which.

This lesson installs Rust with rustup, reads what it installed, explains the stable, beta and nightly channels, and follows the fixed order in which rustup chooses a toolchain. Then you pin a project to Rust 1.99.0, with the component: A part of a toolchain that rustup adds or removes on its own, such as clippy, rustfmt, rust-docs, rust-src or rust-analyzer, or the standard library for one target. and target: The kind of system a program is built for, named by a triple such as aarch64-apple-darwin, x86_64-pc-windows-msvc or wasm32-wasip1. Building for a target needs that target's standard library. it needs, so that every computer that builds it uses the same compiler.

rustup installs Rust, and every tool comes from a toolchain

On macOS and Linux, the install page of rust-lang.org gives one command, which downloads rustup’s installer and runs it: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh. On Windows you download and run rustup-init.exe instead, and you may be asked to install the Visual Studio C++ build tools first. Either way, the installer puts its commands in ~/.cargo/bin (%USERPROFILE%\.cargo\bin on Windows), tries to add that folder to your PATH, and keeps the toolchains in ~/.rustup. Open a new terminal afterwards, because the PATH change may not reach the one you have open.

Rust also needs a linker, the program that joins compiled pieces into one executable, and it uses the system’s. The Rust book’s advice for linker errors is to install a C compiler, which typically includes one: on macOS run xcode-select --install, on Linux install GCC or Clang (on Ubuntu, the build-essential package), and on Windows accept the Visual Studio installer when it is offered.

What rustup installs is a toolchain: one release of rustc, cargo and the standard library for your computer, plus extra tools as components. The default profile adds rust-docs, rustfmt and clippy to the three essentials; the minimal profile installs only rustc, rust-std and cargo, which is why some installs have no cargo fmt. Here is what this computer reports, run in its home folder:

What rustup has installed, and what runs by default Python · versions_session.py
from session import run

# In the home folder, where no toolchain file applies: what rustup has installed, and what runs by default.
run("""
rustup --version
rustup show
rustc --version
cargo --version
""")

Output

$ rustup --version
rustup 1.29.1 (d95a37b6a)
info: This is the version for the rustup toolchain manager, not the rustc compiler.
info: the currently active `rustc` version is `rustc 1.98.0 (88d9e12ae)`
$ rustup show
Default host: aarch64-apple-darwin
rustup home:  ~/.rustup

installed toolchains
--------------------
stable-aarch64-apple-darwin (active, default)
nightly-aarch64-apple-darwin
1.99.0-aarch64-apple-darwin

active toolchain
----------------
name: stable-aarch64-apple-darwin
active because: it's the default toolchain
installed targets:
  aarch64-apple-darwin
$ rustc --version
rustc 1.98.0 (88d9e12ae)
$ cargo --version
cargo 1.98.0 (797e8a9bc)

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 versions_session.py

Three toolchains are installed: stable, nightly and the exact release 1.99.0. The default is stable, and on this computer stable is still 1.98.0, because rustup update has not been run on it since 1.99.0 came out. That is the first reason to pin a project: “stable” means whatever stable you installed last. The commands themselves are not the compilers: the cargo and rustc in ~/.cargo/bin are proxies of rustup, small programs that hand each command to the real toolchain. Step through one command:

Interactive · message by message What runs when you type cargo build Step through one command in the pinned folder ~/pinned. Watch rustup's small program choose a toolchain and hand the command on.
What runs when you type cargo build, step 7 of 7. Messages so far: Your terminal to rustup's cargo: cargo build; rustup's cargo to Toolchain 1.99.0: cargo build; Toolchain 1.99.0 to Your terminal: Compiling … Finished.Your terminalin ~rustup's cargofalls back to the defaultToolchain 1.99.0cargo and rustc 1.99.0cargo buildcargo buildCompiling … Finished

The drawing shows the whole scene; its 7 steps are listed below.

Every step as text
  1. You type a command. You type cargo build. The shell looks for cargo on its PATH and finds it in ~/.cargo/bin, the folder rustup added to the PATH when it was installed.
  2. A proxy, not cargo. The program in ~/.cargo/bin is a proxy: a small program of rustup that only decides which toolchain should run, and then starts that toolchain's own cargo.
  3. It looks for a choice. It checks, in order: a +toolchain argument, the RUSTUP_TOOLCHAIN variable, a directory override, a rust-toolchain.toml file, the default. Here the first three are absent.
  4. The file decides. It finds ~/pinned/rust-toolchain.toml, which names channel 1.99.0. That toolchain is installed, so nothing has to be downloaded.
  5. The real cargo runs. The proxy starts cargo from the 1.99.0 toolchain with the same arguments. That cargo runs rustc from the same toolchain, so the two always match.
  6. The output comes back. What the build prints comes straight back to your terminal. The proxy adds nothing to it.
  7. Elsewhere, the default. In a folder with no toolchain file above it, the same command runs the default toolchain instead: on the computer these sessions ran on, stable was still 1.98.0.

Checkpoint

Check: What rustup installs

  1. Question 1 of 2 In the first session, rustup lists a 1.99.0 toolchain, yet rustc --version in the home folder prints 1.98.0. Why?

    Choose one answer.

    A hint

    Look at which toolchain rustup show marks as the default, and think about what "stable" means on one computer.

    Show the answer: Question 1 of 2

    Answer: The default is the stable toolchain, which was installed while 1.98.0 was current and not updated since

    rustup show lists stable as the default toolchain, and this computer's stable is 1.98.0 because nobody ran rustup update after 1.99.0 came out. The exact toolchain 1.99.0 is installed beside it and runs only where a +1.99.0 argument, an override or a toolchain file selects it.

  2. Question 2 of 2 Rust is installed on a Linux computer, but cargo build fails because it cannot find a linker. What does the Rust book advise?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: Install a C compiler such as GCC or Clang, for example Ubuntu's build-essential package

    The book says Rust needs a linker and that you should install a C compiler if you get linker errors: xcode-select --install on macOS, GCC or Clang on Linux, and the Visual Studio tools on Windows.

Stable, beta and nightly: three channels for three needs

rustup installs toolchains from three release channel: A stream of Rust releases: stable, a new release every six weeks; beta, the next stable release while it is tested; and nightly, built every night with features that are not finished yet.. Each answers a different need:

Channel A new build Use it for
stable every six weeks, with an occasional point release all your work, and everything in this track
beta the next stable release, tested before it ships checking that your project builds on the coming release
nightly every night unfinished features and tools that need them, such as Miri

A toolchain can be named by its channel (stable, beta, nightly) or by an exact release (1.99.0), and a +toolchain argument picks one for a single command. Here the three installed toolchains answer one after the other, and then the stable 1.99.0 and the nightly compile a file that uses an unfinished feature, try blocks:

gated.rs: a program that needs a nightly compiler Rust · gated.rs
// try blocks are an unfinished feature: only a nightly compiler accepts the #![feature] line.
#![feature(try_blocks)]

fn main() {
    let total: Option<u32> = try { "40".parse::<u32>().ok()? + "25".parse::<u32>().ok()? };
    println!("{total:?}");
}
Three toolchains, and a feature only nightly accepts Python · channels_session.py
from session import run

# One computer, three toolchains: a +toolchain argument picks one for a single command.
run("""
rustc +stable --version
rustc +1.99.0 --version
rustc +nightly --version
!rustc +1.99.0 --edition 2024 gated.rs
rustc +nightly --edition 2024 gated.rs
./gated
""")

Output

$ rustc +stable --version
rustc 1.98.0 (88d9e12ae)
$ rustc +1.99.0 --version
rustc 1.99.0 (b940084d7)
$ rustc +nightly --version
rustc 1.101.0-nightly (0abfedbc7)
$ rustc +1.99.0 --edition 2024 gated.rs
error[E0554]: `#![feature]` may not be used on the stable release channel
 --> gated.rs:2:1
  |
2 | #![feature(try_blocks)]
  | ^^^^^^^^^^^^^^^^^^^^^^^

error: aborting due to 1 previous error

For more information about this error, try `rustc --explain E0554`.
[exit status 1]
$ rustc +nightly --edition 2024 gated.rs
$ ./gated
Some(65)

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 channels_session.py

Stable Rust refused the #![feature(try_blocks)] line with error E0554: feature flags “may not be used on the stable release channel”. The nightly compiler accepted it, and the program printed Some(65). This is the rule the Rust book states: to try a feature that is still being worked on, you must use a nightly release and opt in with a flag in your code, while on stable and beta no feature flags are allowed.

Switching everything to nightly for one feature

A whole project on nightly gets a new compiler every night, and an unfinished feature can still change or be removed. Keep stable as the default and use cargo +nightly … for the one command that needs it, or pin one nightly toolchain in that project’s toolchain file.

Checkpoint

Check: Stable, beta and nightly

  1. Question 1 of 2 A crate starts with #![feature(try_blocks)]. Which command builds it?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: cargo +nightly build

    Unfinished features are switched on with #![feature(…)], and only a nightly compiler accepts that line. On stable and beta, rustc stops with E0554, "#![feature] may not be used on the stable release channel".

  2. Question 2 of 2 Why would a team run its tests on the beta toolchain as well as on stable?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: To find problems with the next stable release before it ships

    Each stable release spends a cycle as beta first. Testing on beta shows, weeks in advance, whether your code or its warnings will change with the next stable release.

rustup chooses the toolchain in a fixed order

Each time you run cargo, rustc or another of its commands, rustup looks for a choice in this order and uses the first one it finds, as its book’s chapter on overrides describes:

  1. a +toolchain argument on the command line, such as cargo +beta test;
  2. the RUSTUP_TOOLCHAIN environment variable;
  3. a directory override, set with rustup override set for a folder and the folders inside it;
  4. a rust-toolchain.toml file in the current folder or one above it;
  5. the default toolchain, set with rustup default.

Step through four commands and watch each one stop at the first stage that names a toolchain:

Interactive · stage by stage The order in which rustup chooses a toolchain Step through four commands from the session below. Each one stops at the first stage that names a toolchain.
The order in which rustup chooses a toolchain, step 5 of 5. Showing A +toolchain argument (none given), RUSTUP_TOOLCHAIN (not set), A directory override, rust-toolchain.toml (none in ~ or above), The default toolchain (stable: used). In focus: first-wins.the first one found winsA +toolchain argumentnone givenRUSTUP_TOOLCHAINnot setA directory overrideset with rustup overriderust-toolchain.tomlnone in ~ or aboveThe default toolchainstable: used

The drawing shows the whole scene; its 5 steps are listed below.

Every step as text
  1. rustc --version in ~/pinned. No +toolchain, no variable and no override, so rustup reaches the toolchain file in ~/pinned. It names 1.99.0, and rustc 1.99.0 answers.
  2. rustc +stable --version. The argument +stable comes first in the order, so it wins over the file in the same folder: stable, 1.98.0 on this computer, answers.
  3. With RUSTUP_TOOLCHAIN=nightly. Without a + argument, the variable is next. It names nightly, so the nightly toolchain answers, again before the file is read.
  4. rustc --version in ~. In the home folder there is no override and no toolchain file in it or above it, so rustup falls through to the default: stable.
  5. The first one found wins. A nearer directory override or toolchain file also wins over one further up. Whatever rustup chooses, rustup show active-toolchain says which one and why.

These are the same four commands, run in this computer’s home folder and in ~/pinned, a folder that holds a toolchain file:

Which toolchain answers, and why Python · which_session.py
from session import run

# The same question in two folders, and two ways to overrule the toolchain file for one command.
run("""
rustup show active-toolchain
cd pinned
rustup show active-toolchain
rustc --version
rustc +stable --version
RUSTUP_TOOLCHAIN=nightly rustc --version
rustup override list
""")

Output

$ rustup show active-toolchain
stable-aarch64-apple-darwin (default)
$ cd pinned
$ rustup show active-toolchain
1.99.0-aarch64-apple-darwin (overridden by '~/pinned/rust-toolchain.toml')
$ rustc --version
rustc 1.99.0 (b940084d7)
$ rustc +stable --version
rustc 1.98.0 (88d9e12ae)
$ RUSTUP_TOOLCHAIN=nightly rustc --version
rustc 1.101.0-nightly (0abfedbc7)
$ rustup override list
no overrides

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 which_session.py

rustup show active-toolchain names the toolchain and the reason, which makes it the first command to run when a build behaves differently on two computers. In the home folder the default answered; in ~/pinned the file did, and both +stable and the environment variable overruled the file for one command. rustup override list found no directory overrides. An override is kept in rustup’s own settings on one computer, so it is handy for an experiment, while a toolchain file lives in the project and travels with it to every computer and to CI.

Key idea

rustup uses the first choice it finds: a +toolchain argument, then RUSTUP_TOOLCHAIN, a directory override, a rust-toolchain.toml file, and finally the default. rustup show active-toolchain tells you which one won.

Checkpoint

Check: How rustup chooses a toolchain

  1. Question 1 of 2 In ~/pinned, whose rust-toolchain.toml names 1.99.0, you run RUSTUP_TOOLCHAIN=nightly cargo +stable build. Which toolchain builds?

    Choose one answer.

    A hint

    rustup takes the first choice in its order.

    Show the answer: Question 1 of 2

    Answer: stable

    The order is: a +toolchain argument, RUSTUP_TOOLCHAIN, a directory override, a rust-toolchain.toml file, the default. +stable is first, so stable builds; without it, nightly would, and without both, 1.99.0.

  2. Question 2 of 2 You run rustc --version in ~/pinned/canteen/src, a folder with no toolchain file of its own. Which toolchain answers?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: 1.99.0, from ~/pinned/rust-toolchain.toml in a folder above

    A toolchain file covers the folder it is in and everything below it. That is why one file at the top of a project pins every crate and every command inside it.

A rust-toolchain.toml pins the release, its components and its targets

A project is pinned by one file in its top folder. This one names the exact release, two components that every build of the project needs, and one extra target, WebAssembly with WASI, for which the standard library must be installed:

pinned/rust-toolchain.toml: one release, two components, one target TOML · pinned/rust-toolchain.toml
[toolchain]
channel = "1.99.0"
components = ["clippy", "rustfmt"]
targets = ["wasm32-wasip1"]

Commit the file with the code. Any computer that builds the project then uses Rust 1.99.0, and if that toolchain is not installed yet, rustup installs it on the first command, because automatic installation is on by default (RUSTUP_AUTO_INSTALL=1). Here is what the file selects in ~/pinned:

What the pinned toolchain holds Python · pinned_session.py
from session import run

# What the pinned folder's toolchain holds: the file, the toolchain it selects, its components and targets.
run("""
cd pinned
cat rust-toolchain.toml
rustup show
rustup component list --installed
!rustup doc --path
""")

Output

$ cd pinned
$ cat rust-toolchain.toml
[toolchain]
channel = "1.99.0"
components = ["clippy", "rustfmt"]
targets = ["wasm32-wasip1"]
$ rustup show
Default host: aarch64-apple-darwin
rustup home:  ~/.rustup

installed toolchains
--------------------
stable-aarch64-apple-darwin (default)
nightly-aarch64-apple-darwin
1.99.0-aarch64-apple-darwin (active)

active toolchain
----------------
name: 1.99.0-aarch64-apple-darwin
active because: overridden by '~/pinned/rust-toolchain.toml'
installed targets:
  aarch64-apple-darwin
  thumbv7m-none-eabi
  wasm32-unknown-unknown
  wasm32-wasip1
  wasm32-wasip2
$ rustup component list --installed
cargo-aarch64-apple-darwin
clippy-aarch64-apple-darwin
rust-src
rust-std-aarch64-apple-darwin
rust-std-thumbv7m-none-eabi
rust-std-wasm32-unknown-unknown
rust-std-wasm32-wasip1
rust-std-wasm32-wasip2
rustc-aarch64-apple-darwin
rustfmt-aarch64-apple-darwin
$ rustup doc --path
info: `rust-docs` not installed in toolchain `1.99.0-aarch64-apple-darwin`
help: run `rustup component add --toolchain 1.99.0-aarch64-apple-darwin rust-docs` to install it
error: unable to view documentation which is not installed
[exit status 1]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 pinned_session.py

The active toolchain is 1.99.0, “overridden by” the file. Its components include clippy and rustfmt, which the file asks for, and rust-src, the standard library’s source code, but not rust-docs, so rustup doc cannot open the offline documentation until rustup component add rust-docs installs it: the help line says exactly that. The installed targets are the host, aarch64-apple-darwin, plus four that were added to this toolchain, wasm32-wasip1 among them.

A target is named by a triple such as aarch64-apple-darwin: the processor, the vendor and the operating system. Rust’s platform support page sorts targets into tiers by what the project promises for them:

  • Tier 1 with host tools, “guaranteed to work” and tested on every change: eight targets, among them aarch64-apple-darwin, x86_64-unknown-linux-gnu and x86_64-pc-windows-msvc.
  • Tier 2 with host tools, “guaranteed to build”, with the compiler itself available there: among others x86_64-apple-darwin, Macs with Intel processors.
  • Tier 2, “guaranteed to build”, for compiling from another computer: wasm32-wasip1 for WebAssembly and thumbv7m-none-eabi for Cortex-M chips, which has no std, only the core and alloc parts of the standard library.

Two platform changes to know

Intel Macs moved from Tier 1 to Tier 2 with host tools in Rust 1.90, so they are still built but no longer tested on every change. Windows on Arm, aarch64-pc-windows-msvc, became Tier 1 in Rust 1.91.

The toolchain file says which compiler builds the project. A package can also say which is the oldest release it supports, with rust-version in its Cargo.toml, and Cargo then refuses an older compiler with a clear message instead of a confusing error later:

rust-version: the oldest Rust a package supports Python · msrv_session.py
from session import run

# A package that says it needs Rust 1.99 or later, built with the pinned 1.99.0 and then with this computer's stable.
run("""
cd pinned/canteen
cat Cargo.toml
cargo run
!cargo +stable run
""")

Output

$ cd pinned/canteen
$ cat Cargo.toml
[package]
name = "canteen"
version = "0.1.0"
edition = "2024"
rust-version = "1.99"

[dependencies]
$ cargo run
   Compiling canteen v0.1.0 (~/pinned/canteen)
    Finished `dev` profile [unoptimized + debuginfo] target(s) in …
     Running `target/debug/canteen`
canteen built with a Rust new enough for it
$ cargo +stable run
error: rustc 1.98.0 is not supported by the following package:
  canteen@0.1.0 requires rustc 1.99
[exit status 101]

Recorded with Python 3.14.8 on macOS 26 arm64. To run it yourself: mise exec python@3.14.8 -- python3 msrv_session.py

With the pinned 1.99.0 the package built and ran. With +stable, this computer’s 1.98.0, Cargo stopped before compiling anything: rustc 1.98.0 “is not supported”, because canteen requires 1.99.

Checkpoint

Check: Pinning with rust-toolchain.toml

  1. Question 1 of 2 Which rust-toolchain.toml pins Rust 1.99.0 with Clippy and the wasm32-wasip1 target?

    Choose one answer.

    Show the answer: Question 1 of 2

    Answer: [toolchain] channel = "1.99.0" components = ["clippy"] targets = ["wasm32-wasip1"]

    A toolchain file has a [toolchain] table. channel names an exact release such as "1.99.0" (or a channel), components lists extra tools such as clippy and rustfmt, and targets lists extra standard libraries to install.

  2. Question 2 of 2 rustup doc --path says that rust-docs is not installed in the toolchain 1.99.0. What fixes it?

    Choose one answer.

    Show the answer: Question 2 of 2

    Answer: rustup component add --toolchain 1.99.0-aarch64-apple-darwin rust-docs

    Components are added per toolchain with rustup component add, and the error's own help line gives the command. Listing rust-docs under components in the toolchain file would install it on every computer.

Practise: pin a project of your own

Make a folder for a project, and write a rust-toolchain.toml in it that pins Rust 1.99.0 with clippy, rustfmt and the wasm32-wasip1 target, like the file above. Then, in that folder, run rustup show active-toolchain and rustc --version, and compare with the session in the previous section: the first line should name 1.99.0-<your host>, overridden by your file, and the second rustc 1.99.0. If rustup starts downloading, the release or one of its parts was not installed yet, and the file is doing its job.

TOML ↔ JSON Converter Paste your rust-toolchain.toml to check that it is valid TOML and see the keys and values rustup will read.

Then try the questions on channels, the order rustup follows and toolchain files. A wrong answer shows its reason straight away, and that idea comes back before the others:

Practice that adapts to you

Practise this lesson

11 questions about 4 ideas of this lesson. Each answer is explained at once, and what you get right is kept in this browser.

  1. Question 1 of 11 What is the cargo program in ~/.cargo/bin?

    Choose one answer.

    Show the answer: Question 1 of 11

    Answer: A proxy of rustup that hands each command to the real cargo of the toolchain that applies

    rustup puts small proxies named cargo, rustc and so on in ~/.cargo/bin. Each one finds the toolchain that applies and starts that toolchain's own program, which is why two folders can run two different compilers.

  2. Question 2 of 11 A teammate installed Rust with the minimal profile, and cargo fmt says rustfmt is not installed. What happened, and what fixes it?

    Choose one answer.

    Show the answer: Question 2 of 11

    Answer: The minimal profile has only rustc, rust-std and cargo; rustup component add rustfmt adds it

    Profiles only decide what rustup installs at first. The minimal profile gets a working compiler, rustc, rust-std and cargo, and any component can be added later with rustup component add.

  3. Question 3 of 11 Which command moves the stable toolchain to the newest stable release?

    Choose one answer.

    Show the answer: Question 3 of 11

    Answer: rustup update

    rustup update fetches the newest release of each installed channel. An exact toolchain such as 1.99.0 never changes, which is why projects pin one.

  4. Question 4 of 11 Which of these need a nightly toolchain? Choose every one.

    Choose every answer that is right.

    Show the answer: Question 4 of 11

    Answer:

    • Running Miri, the interpreter that finds undefined behaviour
    • A #![feature(…)] attribute for an unfinished feature

    Nightly is for what is not finished: feature flags and tools such as Miri. Editions, stable targets and everything in this track's examples work on stable.

  5. Question 5 of 11 Rust 1.99.0 is the newest stable release, and the beta channel carries 1.100.0. When does 1.100.0 become stable?

    Choose one answer.

    Show the answer: Question 5 of 11

    Answer: At the next stable release, six weeks after 1.99.0

    The channels are a train: nightly every night, beta for one cycle, stable every six weeks. 1.100.0 is on beta now and becomes stable at the next release, six weeks after 1.99.0.

  6. Question 6 of 11 Put the ways of choosing a toolchain in the order rustup checks them, first to last.

    Give each item its position, from 1 (first).

    Show the answer: Question 6 of 11

    Answer:

    1. A +toolchain argument on the command line
    2. The RUSTUP_TOOLCHAIN environment variable
    3. A directory override set with rustup override
    4. A rust-toolchain.toml file in this folder or one above
    5. The default toolchain

    rustup checks a +toolchain argument, then RUSTUP_TOOLCHAIN, then a directory override, then a toolchain file, and uses the default only when none of these names a toolchain. The first one found wins.

  7. Question 7 of 11 Which command tells you which toolchain will run in the current folder, and why?

    Choose one answer.

    Show the answer: Question 7 of 11

    Answer: rustup show active-toolchain

    rustup show active-toolchain answers both questions at once, which is why it is the first command to compare when two computers build the same project differently.

  8. Question 8 of 11 Every teammate and the CI machine must build a project with Rust 1.99.0. Which do you use, and why?

    Choose one answer.

    Show the answer: Question 8 of 11

    Answer: A rust-toolchain.toml committed in the project, because it travels with the code to every computer

    Overrides, defaults and environment variables live on one computer. A toolchain file lives in the project, so it is the way to give everyone, CI included, the same compiler.

  9. Question 9 of 11 A new teammate clones a project whose rust-toolchain.toml names 1.99.0, but they only have stable 1.98.0. What happens on their first cargo build?

    Choose one answer.

    Show the answer: Question 9 of 11

    Answer: rustup installs 1.99.0 and then builds with it

    With RUSTUP_AUTO_INSTALL at its default of 1, rustup installs the toolchain the file names, with its components and targets, before running the command. Set it to 0 to make a missing toolchain an error instead.

  10. Question 10 of 11 canteen's Cargo.toml has rust-version = "1.99". What does cargo +stable run do on the computer of this lesson, whose stable is 1.98.0?

    Choose one answer.

    Show the answer: Question 10 of 11

    Answer: It stops before compiling, saying rustc 1.98.0 is not supported because canteen requires 1.99

    rust-version in Cargo.toml says which releases a package supports, and Cargo reports an older toolchain as an error before compiling. It complements the toolchain file, which says which release builds the project.

  11. Question 11 of 11 Which of these targets is Tier 1, guaranteed to work?

    Choose one answer.

    Show the answer: Question 11 of 11

    Answer: aarch64-apple-darwin, macOS on Apple silicon

    Tier 1 targets are tested on every change. Today they include Linux, Windows and macOS on Apple silicon; Intel Macs, WebAssembly and microcontrollers are Tier 2.

Interview questions

Warm-up: what is the difference between rustup, rustc and cargo?

rustc is the Rust compiler: it turns source files into a library or an executable. Cargo is Rust’s build tool and package manager: it reads Cargo.toml, fetches dependencies, calls rustc with the right options for every crate, and runs tests, benchmarks and documentation builds. rustup is neither; it installs and manages toolchains, each one a release of rustc, Cargo and the standard library, and its proxies in ~/.cargo/bin decide which toolchain runs each command, from a +toolchain argument, RUSTUP_TOOLCHAIN, a directory override, a rust-toolchain.toml file or the default. A good answer adds the practical consequence: when a build behaves differently on two computers, rustup show active-toolchain and rustc --version show which compiler each one really uses.

Model answers open with any pass: ₹79 for 1 week ($2.99), one payment that never renews.

  1. Mid to senior

    Every laptop builds the project, but CI fails the morning after a new stable release: a new Clippy lint fires, and CI treats warnings as errors. How do you make builds reproducible without falling behind on Rust releases?

    Model answer, Pro. Model answers open with any pass; prices are in the notice on this page. First step and follow-ups

  2. Mid to senior

    Your library promises to build on Rust 1.85, while the team develops on the newest stable release. How do you set this up, and how do you check the promise on every change?

    Model answer, Pro. First step and follow-ups

Key takeaways

  • rustup installs toolchains, each a release of rustc, cargo and the standard library, and its commands in ~/.cargo/bin start the toolchain that applies; Rust links with the system’s linker, so install one first.
  • Stable ships every six weeks and is for all your work, beta is the next stable release to test against, and nightly is only for unfinished features, which stable refuses with E0554.
  • rustup uses the first choice it finds: a +toolchain argument, RUSTUP_TOOLCHAIN, a directory override, a rust-toolchain.toml file, then the default, and rustup show active-toolchain says which one won.
  • A committed rust-toolchain.toml pins the release, its components and its targets for every computer, while rust-version in Cargo.toml states the oldest release a package supports.

Terms in this lesson

component
A part of a toolchain that rustup adds or removes on its own, such as clippy, rustfmt, rust-docs, rust-src or rust-analyzer, or the standard library for one target.
release channel
A stream of Rust releases: stable, a new release every six weeks; beta, the next stable release while it is tested; and nightly, built every night with features that are not finished yet.
rustup
The installer and manager of Rust toolchains. Its commands in ~/.cargo/bin, cargo and rustc among them, are proxies that choose a toolchain for each run and hand the command to that toolchain's own program.
target
The kind of system a program is built for, named by a triple such as aarch64-apple-darwin, x86_64-pc-windows-msvc or wasm32-wasip1. Building for a target needs that target's standard library.
toolchain
One installed release of Rust's tools for one host: rustc, Cargo and the standard library, plus components such as rustfmt and Clippy. rustup names toolchains such as stable-aarch64-apple-darwin or 1.99.0-aarch64-apple-darwin.

References

Related tools

Report a problem with this lesson

Quick answers and tool search

Type to search tools or to get a quick answer, for example 18% of 2500. Use the up and down arrow keys to move through the results, Enter to choose, and Escape to close.