Skip to content

Commit e5ec01c

Browse files
committed
Auto merge of #14336 - soloturn:master, r=weihanglo
faq: rephrase offline usage. ### What does this PR try to resolve? fixes #14330. FAQ tried to explain the history of cargo offline, and thus was distracting from the core flags.
2 parents 5ff9328 + 16540c2 commit e5ec01c

File tree

1 file changed

+13
-38
lines changed

1 file changed

+13
-38
lines changed

src/doc/src/faq.md

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ verified against consistent versions of dependencies, like when
131131
However, this determinism can give a false sense of security because
132132
`Cargo.lock` does not affect the consumers of your package, only `Cargo.toml` does that.
133133
For example:
134-
- [`cargo install`] will select the latest dependencies unless `--locked` is
135-
passed in.
134+
- [`cargo install`] will select the latest dependencies unless
135+
`[--locked`](commands/cargo.html#option-cargo---locked) is passed in.
136136
- New dependencies, like those added with [`cargo add`], will be locked to the latest version
137137

138138
The lockfile can also be a source of merge conflicts.
@@ -174,42 +174,17 @@ but others were accidentally forgotten.
174174

175175
## How can Cargo work offline?
176176

177-
Cargo is often used in situations with limited or no network access such as
178-
airplanes, CI environments, or embedded in large production deployments. Users
179-
are often surprised when Cargo attempts to fetch resources from the network, and
180-
hence the request for Cargo to work offline comes up frequently.
181-
182-
Cargo, at its heart, will not attempt to access the network unless told to do
183-
so. That is, if no crates come from crates.io, a git repository, or some other
184-
network location, Cargo will never attempt to make a network connection. As a
185-
result, if Cargo attempts to touch the network, then it's because it needs to
186-
fetch a required resource.
187-
188-
Cargo is also quite aggressive about caching information to minimize the amount
189-
of network activity. It will guarantee, for example, that if `cargo build` (or
190-
an equivalent) is run to completion then the next `cargo build` is guaranteed to
191-
not touch the network so long as `Cargo.toml` has not been modified in the
192-
meantime. This avoidance of the network boils down to a `Cargo.lock` existing
193-
and a populated cache of the crates reflected in the lock file. If either of
194-
these components are missing, then they're required for the build to succeed and
195-
must be fetched remotely.
196-
197-
As of Rust 1.11.0, Cargo understands a new flag, `--frozen`, which is an
198-
assertion that it shouldn't touch the network. When passed, Cargo will
199-
immediately return an error if it would otherwise attempt a network request.
200-
The error should include contextual information about why the network request is
201-
being made in the first place to help debug as well. Note that this flag *does
202-
not change the behavior of Cargo*, it simply asserts that Cargo shouldn't touch
203-
the network as a previous command has been run to ensure that network activity
204-
shouldn't be necessary.
205-
206-
The `--offline` flag was added in Rust 1.36.0. This flag tells Cargo to not
207-
access the network, and try to proceed with available cached data if possible.
208-
You can use [`cargo fetch`] in one project to download dependencies before
209-
going offline, and then use those same dependencies in another project with
210-
the `--offline` flag (or [configuration value][offline config]).
211-
212-
For more information about vendoring, see documentation on [source
177+
The [`--offline`](commands/cargo.html#option-cargo---offline) or
178+
[`--frozen`](commands/cargo.html#option-cargo---frozen) flags tell Cargo to not
179+
touch the network. It returns an error in case it would access the network.
180+
You can use [`cargo fetch`] in one project to download
181+
dependencies before going offline, and then use those same dependencies in
182+
another project. Refer to [configuration value][offline config]) to set via
183+
Cargo configuration.
184+
185+
186+
187+
Vendoring is also related, for more information see documentation on [source
213188
replacement][replace].
214189

215190
[replace]: reference/source-replacement.md

0 commit comments

Comments
 (0)