appendix

This appendix contains instructions for installing the command-line utilities required to compile and run the code samples in this book. These instructions are provided for convenience, but you aren’t required to follow these procedures if you already have the tools required, or prefer to install them another way.

Installing tools for this book

To compile and run the code samples provided in this book, you must first install the necessary prerequisite dependencies.

Installing tools on macOS using Homebrew

$ brew install git

On macOS, you’ll need to install the Xcode command line tools:

$ sudo xcode-select --install

Installing tools on Linux systems

On Debian-based systems:

$ apt install git build-essential

On Red Hat-based systems:

$ yum install git make automake gcc gcc-c++

Tip You may want to install clang rather than CCC because it tends to have better compile times.

Installing rustup on Linux- or UNIX-based systems

To install rustup on Linux- or UNIX-based operating systems, including macOS, run the following:

$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

Once you’ve installed rustup, it’s recommended you make sure both the stable and nightly toolchains are installed:

$ rustup toolchain install stable nightly
...

Installing tools on Windows

If you’re using a Windows-based OS, you’ll need to download the latest copy of rustup from https://rustup.rs/. Prebuilt Windows binaries for clang can be downloaded from https://releases.llvm.org/download.html.

Alternatively, on Windows, you may use Windows Subsystem for Linux (WSL, https://docs.microsoft.com/en-us/windows/wsl/) and follow the earlier instructions for installation on Linux. For many users, this may be the easiest way to work with the code samples.

Managing rustc and other Rust components with rustup

With rustup installed, you’ll need to install the Rust compiler and related tools. At a minimum, it’s recommended that you install the stable and nightly channels of Rust.

Installing rustc and other components

It’s recommended you install both stable and nightly toolchains by default, but generally, you should prefer working with stable when possible. Run the following to install both toolchains:

$ rustup default stable                
...
$ rustup toolchain install nightly     

Installs stable Rust and makes it the default toolchain

Installs nightly Rust

Additionally, throughout this book, we make use of Clippy and rustfmt. These are both installed using rustup:

$ rustup component add clippy rustfmt

Switching default toolchains with rustup

When working with Rust, you may frequently find yourself switching between stable and nightly toolchains. rustup makes this relatively easy:

$ rustup default stable    
$ rustup default nightly   

Switches default to stable toolchain

Switches default to nightly toolchain

Updating Rust components

rustup makes it easy to keep components up to date. To update all the installed toolchains and components, simply run the following:

$ rustup update

Under normal circumstances, you only need to run update when there are major new releases. There may occasionally be problems in nightly that require an update, but this tends to be infrequent. If your installation is working, it’s recommended you avoid upgrading too frequently (i.e., daily) because you’re more likely to run into problems.

Note Updating all Rust components causes all toolchains and components to be downloaded and updated, which may take some time on bandwidth-limited systems.

Installing HTTPie

HTTPie is a CLI tool for making HTTP requests and is included in many popular package managers, such as Homebrew, apt, yum, choco, Nixpkgs, and more. If HTTPie is not available in your package management tool, you can fall back to using Python pip to install HTTPie:

# Install httpie
$ python -m pip install httpie