mdBook Installation Guide
for mdBook v0.4.40+
mdBook is a command-line tool to create online books with Markdown. This guide will show you how to install mdBook on your system.
Prerequisites
Before installing mdBook, you’ll need one of the following depending on your installation method:
For Cargo Installation (Recommended):
- Rust and Cargo: You need Rust 1.65+ installed on your system (see mdBook documentation for current requirements)
- Install Rust from rustup.rs
For Package Manager Installation:
- Package manager specific to your operating system (Homebrew, Snap, etc.)
For Binary Installation:
- No additional prerequisites required
Installation Methods
Method 1: Using Cargo (Recommended)
This method provides the latest features and is maintained by the core team.
Step 1: Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env
Step 2: Install mdBook
cargo install mdbook
Optional: Install additional renderers
# For PDF output support
cargo install mdbook-pdf
# For presentation slides
cargo install mdbook-presentation
# For Mermaid diagrams
cargo install mdbook-mermaid
Method 2: Using Package Managers
On macOS with Homebrew:
brew install mdbook
On Linux with Snap:
sudo snap install mdbook
On Arch Linux:
sudo pacman -S mdbook
On Ubuntu/Debian (via cargo-deb):
Requires Cargo installed (see Cargo Installation method).
# First install cargo-deb
cargo install cargo-deb
# Then install mdbook
cargo deb --install mdbook
On Windows with Chocolatey:
Chocolatey/Scoop commands require PowerShell or Command Prompt.
choco install mdbook
On Windows with Scoop:
scoop install mdbook
Method 3: Pre-built Binaries
-
Go to the releases page: Visit mdBook releases on GitHub
-
Download the appropriate binary:
- For Linux:
mdbook-v[version]-x86_64-unknown-linux-gnu.tar.gz - For macOS:
mdbook-v[version]-x86_64-apple-darwin.tar.gz - For Windows:
mdbook-v[version]-x86_64-pc-windows-msvc.zip
- For Linux:
-
Extract and install:
# Linux/macOS tar xzf mdbook-v[version]-x86_64-unknown-linux-gnu.tar.gz sudo mv mdbook /usr/local/bin/ # Or add to your PATH mkdir -p ~/.local/bin mv mdbook ~/.local/bin/# Windows (PowerShell) Expand-Archive -Path mdbook-*.zip -DestinationPath . [Environment]::SetEnvironmentVariable('PATH', "$env:PATH;$(Get-Location)", 'User')
Method 4: Building from Source
For the latest development version or custom builds:
# Clone the repository
git clone https://github.com/rust-lang/mdBook.git
cd mdBook
# Build and install
cargo install --path .
Verification
After installation, verify that mdBook is working correctly:
Check command availability:
mdbook --help
Check mdBook version:
mdbook --version
You should see output like:
mdbook v0.4.40
Getting Started
Optional: Verify book building (requires existing project created with mdbook init):
# Generate static HTML files
mdbook build
# Or serve locally with live reload
mdbook serve
View the book:
- Built files are in the
book/directory - When using
mdbook serve, visithttp://localhost:3000