Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update “How can Cargo work offline?” FAQ section in Cargo book #14330

Closed
soloturn opened this issue Jul 31, 2024 · 2 comments · Fixed by #14336
Closed

Update “How can Cargo work offline?” FAQ section in Cargo book #14330

soloturn opened this issue Jul 31, 2024 · 2 comments · Fixed by #14336
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-offline Area: offline mode C-bug Category: bug S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review

Comments

@soloturn
Copy link
Contributor

soloturn commented Jul 31, 2024

Problem

cargo flags --frozen and --offline are confusing. the cargo book says:

_As of Rust 1.11.0, Cargo understands a new flag, --frozen, which is an assertion that it shouldn’t touch the network. When passed, Cargo will immediately return an error if it would otherwise attempt a network request. The error should include contextual information about why the network request is being made in the first place to help debug as well. Note that this flag does not change the behavior of Cargo, it simply asserts that Cargo shouldn’t touch the network as a previous command has been run to ensure that network activity shouldn’t be necessary.

The --offline flag was added in Rust 1.36.0. This flag tells Cargo to not access the network, and try to proceed with available cached data if possible. You can use cargo fetch in one project to download dependencies before going offline, and then use those same dependencies in another project with the --offline flag (or configuration value)._

if you paste here a better description what the difference is i d create a pull request to adjust. if it is really the same, maybe drop one of the flags. it sounds weird that experienced programmers use both flags then, like COSMIC desktop build vendored with:
cargo build --release --frozen --offline

reference:

@soloturn soloturn added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jul 31, 2024
@ChrisDenton
Copy link
Member

The documentation seems clear to me: https://doc.rust-lang.org/cargo/commands/cargo-build.html#manifest-options

--locked

Asserts that the exact same dependencies and versions are used as when the existing Cargo.lock file was originally generated. Cargo will exit with an error when either of the following scenarios arises:

  • The lock file is missing.
  • Cargo attempted to change the lock file due to a different dependency resolution.

It may be used in environments where deterministic builds are desired, such as in CI pipelines.

--offline

Prevents Cargo from accessing the network for any reason. Without this flag, Cargo will stop with an error if it needs to access the network and the network is not available. With this flag, Cargo will attempt to proceed without the network if possible.

Beware that this may result in different dependency resolution than online mode. Cargo will restrict itself to crates that are downloaded locally, even if there might be a newer version as indicated in the local copy of the index. See the cargo-fetch(1) command to download dependencies before going offline.

May also be specified with the net.offline config value.

--frozen

Equivalent to specifying both --locked and --offline.

Can you say what you find confusing?

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Aug 1, 2024
@weihanglo
Copy link
Member

Hmm… just realized they were talking about https://doc.rust-lang.org/cargo/faq.html#how-can-cargo-work-offline. That part needs to update to what ChrisDenton posted accordingly.

@weihanglo weihanglo added A-documenting-cargo-itself Area: Cargo's documentation S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review A-offline Area: offline mode and removed S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. labels Aug 1, 2024
@weihanglo weihanglo changed the title drop flag --frozen or --offline, or correct cargo book so difference between both is clear Update “How can Cargo work offline?” FAQ section in Cargo book Aug 1, 2024
soloturn added a commit to soloturn/cargo that referenced this issue Aug 1, 2024
bors added a commit that referenced this issue Aug 2, 2024
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.
@bors bors closed this as completed in 16540c2 Aug 2, 2024
stupendoussuperpowers pushed a commit to stupendoussuperpowers/cargo that referenced this issue Aug 7, 2024
link flags, fixes rust-lang#14330.

Co-authored-by: Weihang Lo <[email protected]>
antoniospg pushed a commit to antoniospg/cargo that referenced this issue Sep 8, 2024
link flags, fixes rust-lang#14330.

Co-authored-by: Weihang Lo <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation A-offline Area: offline mode C-bug Category: bug S-accepted Status: Issue or feature is accepted, and has a team member available to help mentor or review
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants