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

cargo requires network acces for build when it should not #7582

Closed
iu0zjp2 opened this issue Nov 12, 2019 · 0 comments · Fixed by #7655
Closed

cargo requires network acces for build when it should not #7582

iu0zjp2 opened this issue Nov 12, 2019 · 0 comments · Fixed by #7655
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug

Comments

@iu0zjp2
Copy link
Contributor

iu0zjp2 commented Nov 12, 2019

Problem

0.37 with --offline requires network access for build but 0.35 did not for -Z offline.

According to cargo documentation:
"Cargo, at its heart, will not attempt to access the network unless told to do so. That is, if no crates comes from crates.io, a git repository, or some other network location, Cargo will never attempt to make a network connection."

Steps

  1. cargo new a
  2. add dependencies and patches to Cargo.toml, see sample below
  3. cargo build --offline

What happens:

error: failed to load source for a dependency on `memchr`

Caused by:
  Unable to update registry `https://github.com/rust-lang/crates.io-index`

Caused by:
  unable to fetch registry `https://github.com/rust-lang/crates.io-index` in offline mode
Try running without the offline flag, or try running `cargo fetch` within your project directory before going offline.

Expected:

Compiling memchr v2.2.1 (...)
Compiling a v0.1.0 (...)
 Finished dev [unoptimized + debuginfo] target(s) in 2.75s

Cargo.toml

[package]
name = "a"
version = "0.1.0"
authors = ["a@localhost"]
edition = "2018"

[dependencies]
memchr = "2"

[patch.crates-io]
memchr = { path = "path/to/local/copy/of/memchr/source" }

Possible Solution(s)

The change was introduced by #6871, the simplest would be to remove the repo check in update_index. (I use this as a workaround and everything seems to work fine.)

Or maybe propagate an "advanced usage" flag there, which would be set if e.g. there is a patch in Cargo.toml, and the set flag would prevent early termination. Or maybe even a "keep going" command line flag, which would instruct cargo to only bail out if there is an actual problem.

Notes

Output of cargo version:
latest test with: cargo 1.36.0 from debian cago 0.37.0-3.

@iu0zjp2 iu0zjp2 added the C-bug Category: bug label Nov 12, 2019
@ehuss ehuss added the A-networking Area: networking issues, curl, etc. label Dec 3, 2019
@bors bors closed this as completed in 76cdf93 Dec 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-networking Area: networking issues, curl, etc. C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants