The following steps install the latest stable version of the Rust compiler. Rust’s stability guarantees ensure that all the examples in the book that compile will continue to compile with newer Rust versions. The output might differ slightly between versions, because Rust often improves error messages and warnings. In other words, any newer, stable version of Rust you install using these steps should work as expected with the content of this book.

    In this chapter and throughout the book, we’ll show some commands used in the terminal. Lines that you should enter in a terminal all start with $. You don’t need to type in the $ character; it’s the command line prompt shown to indicate the start of each command. Lines that don’t start with $ typically show the output of the previous command. Additionally, PowerShell-specific examples will use rather than $.

    If you’re using Linux or macOS, open a terminal and enter the following command:

    The command downloads a script and starts the installation of the rustup tool, which installs the latest stable version of Rust. You might be prompted for your password. If the install is successful, the following line will appear:

    1. Rust is installed now. Great!

    You will also need a linker, which is a program that Rust uses to join its compiled outputs into one file. It is likely you already have one. If you get linker errors, you should install a C compiler, which will typically include a linker. A C compiler is also useful because some common Rust packages depend on C code and will need a C compiler.

    1. $ xcode-select --install

    Linux users should generally install GCC or Clang, according to their distribution’s documentation. For example, if you use Ubuntu, you can install the build-essential package.

    On Windows, go to and follow the instructions for installing Rust. At some point in the installation, you’ll receive a message explaining that you’ll also need the MSVC build tools for Visual Studio 2013 or later. To acquire the build tools, you’ll need to install Visual Studio 2022. When asked which workloads to install, include:

    • “Desktop Development with C++”
    • The Windows 10 or 11 SDK

    The rest of this book uses commands that work in both cmd.exe and PowerShell. If there are specific differences, we’ll explain which to use.

    Troubleshooting

    To check whether you have Rust installed correctly, open a shell and enter this line:

    You should see the version number, commit hash, and commit date for the latest stable version that has been released in the following format:

    1. rustc x.y.z (abcabcabc yyyy-mm-dd)

    If you see this information, you have installed Rust successfully! If you don’t see this information, check that Rust is in your %PATH% system variable as follows.

    1. > echo %PATH%

    In PowerShell, use:

    In Linux and macOS, use:

    1. echo $PATH

    If that’s all correct and Rust still isn’t working, there are a number of places you can get help. The easiest is the #beginners channel on . There, you can chat with other Rustaceans (a silly nickname we call ourselves) who can help you out. Other great resources include the Users forum and .

    Once Rust is installed via rustup, when a new version of Rust is released, updating to the latest version is easy. From your shell, run the following update script:

    1. $ rustup update

    To uninstall Rust and , run the following uninstall script from your shell:

    Local Documentation

    The installation of Rust also includes a local copy of the documentation, so you can read it offline. Run rustup doc to open the local documentation in your browser.