From a4f94174155ff413f23af936c3a31ab71f11cb6f Mon Sep 17 00:00:00 2001 From: Chris Krycho Date: Fri, 21 Mar 2025 08:40:52 -0600 Subject: [PATCH] Ch. 01: Show how to work offline Fixes #3279 --- src/ch01-01-installation.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/ch01-01-installation.md b/src/ch01-01-installation.md index 55636c09b3..cf2ca86db0 100644 --- a/src/ch01-01-installation.md +++ b/src/ch01-01-installation.md @@ -142,6 +142,26 @@ integrated development environments (IDEs) have built-in support for Rust. You can always find a fairly current list of many editors and IDEs on [the tools page][tools] on the Rust website. +### Working Offline with This Book + +In several examples, we will use Rust packages beyond the standard library. To +work through those examples, you will either need to have an internet connection +or to have downloaded those dependencies ahead of time. To download the +dependencies ahead of time, you can run the following commands. (We’ll explain +what `cargo` is and what each of these commands does in detail later.) + +```console +$ cargo new get-dependencies +$ cd get-dependencies +$ cargo add rand@0.8.5 trpl@0.2.0 +``` + +This will cache the downloads for these packages so you will not need to +download them later. Once you have run this command, you do not need to keep the +`get-dependencies` folder. If you have run this command, you can use the +`--offline` flag with all `cargo` commands in the rest of the book to use these +cached versions instead of attempting to use the network. + [otherinstall]: https://forge.rust-lang.org/infra/other-installation-methods.html [install]: https://www.rust-lang.org/tools/install [msvc]: https://rust-lang.github.io/rustup/installation/windows-msvc.html