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.
To compile and run the code samples provided in this book, you must first install the necessary prerequisite dependencies.
$ brew install git
On macOS, you’ll need to install the Xcode command line tools:
$ sudo xcode-select --install
$ apt install git build-essential
$ 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.
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 ...
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.
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.
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
Additionally, throughout this book, we make use of Clippy and rustfmt. These are both installed using rustup
:
$ rustup component add clippy rustfmt
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
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.
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