Sub topic 3
Checking that the install worked
This chapter assumes you have already run the rustup installer from the previous chapter. It also assumes you can open a terminal and know that the PATH environment variable is the list of directories your shell searches for commands. By the end, you will be able to confirm that the tools are installed and tell which copy of each tool your shell runs.
Run the three version commands
Each tool prints its version when you pass --version. Running all three confirms that the compiler, the build tool, and the toolchain manager are reachable from your shell.
rustc --version
cargo --version
rustup --versionThe output looks like this. Your version numbers and dates will differ.
rustc 1.xx.x (abcdef123 20xx-xx-xx)
cargo 1.xx.x (abcdef123 20xx-xx-xx)
rustup 1.xx.x (abcdef123 20xx-xx-xx)Each line proves something different:
| Command | Tool | What a successful result tells you |
|---|---|---|
| `rustc --version` | The compiler | A toolchain is installed and selected |
| `cargo --version` | The build tool | Cargo is installed and on your `PATH` |
| `rustup --version` | The toolchain manager | You can update and switch toolchains later |
rustc and cargo normally report matching release numbers because they ship together in one toolchain. rustup has its own version number.
If the command is not found
Run each command in a fresh terminal. The installer adds Cargo's bin directory to your shell profile, but a terminal that was already open does not reread the profile. A message such as command not found or 'rustc' is not recognized right after installing usually means you are in an old session.
On Linux and macOS you can load the change into the current session without opening a new one:
. "$HOME/.cargo/env"If a new terminal still cannot find the tools, the problem is in your PATH setup. The troubleshooting chapter covers that case.
See which copy you are running
A passing version check does not tell you where the program came from. A system package manager may have installed an older rustc earlier, and your shell may find that one first. Ask the shell for the full path.
which rustc
which cargoOn Windows PowerShell, use Get-Command rustc and Get-Command cargo. In Command Prompt, use where rustc.
With a normal rustup install, both paths point into the .cargo/bin directory of your home folder, for example /home/you/.cargo/bin/rustc. The files in that directory are small proxies that rustup provides. A proxy looks up the active toolchain and runs the real compiler from it. That is why rustup update can change your compiler version without changing any path.
If the path points somewhere else, such as /usr/bin/rustc, a second installation is shadowing the rustup one. Remove it or move ~/.cargo/bin earlier in your PATH.
Ask rustup what it installed
For a fuller report, use rustup show. It lists the installed toolchains, the active one, and the default host platform.
rustup showLook for a stable toolchain marked as the default. The installer chooses the stable channel unless you override it, and a later chapter covers other channels.
The diagram shows the order of the checks and what to do at each failure.
Common mistakes
- Checking only
rustc. Cargo is a separate executable, and you will use it for almost everything else in this tutorial. - Reading a version failure as a failed install. The files are usually present and only the
PATHis stale. - Ignoring a path outside
.cargo/bin. Everything may seem to work now, butrustup updatewill not change the compiler you are actually running.
Exercise
You run rustc --version and it works, then run which rustc and see /usr/bin/rustc. Why does this matter, and how can you fix it?
Show answer
A /usr/bin path means the shell is running a copy of the compiler from a system package, not the rustup proxy in ~/.cargo/bin. rustup update will not change that copy, so your compiler version will not follow the toolchain you manage. Fix it by removing the system package, or by putting ~/.cargo/bin before /usr/bin in your PATH. Then run which rustc again and confirm that it points into .cargo/bin.