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

-Z offline actively breaks building crate offline #6014

Closed
matthiaskrgr opened this issue Sep 12, 2018 · 0 comments · Fixed by #6814
Closed

-Z offline actively breaks building crate offline #6014

matthiaskrgr opened this issue Sep 12, 2018 · 0 comments · Fixed by #6814
Labels
C-bug Category: bug

Comments

@matthiaskrgr
Copy link
Member

cargo 1.30.0-nightly (b917e3524 2018-09-09)
I cargo newed a dummy project with cargo as git rependency

[dependencies]
cargo = { git = "https://github.com/rust-lang/cargo", rev = "9311f6d439e09da3ab918397a425be57da13f04a" }

and built it with a cargo cache starting from scratch:

CARGO_HOME=/tmp/cargohome cargo build

and waited for everything to be downloaded.
I can see that the cargo git repo is cloned and the respective git commit checked out:

$ cd /tmp/cargohome/git
$ fd --max-depth 2

checkouts
checkouts/cargo-e7ff1db891893a9e
db
db/cargo-e7ff1db891893a9e

Next I tried to rebuild the dummy package from scratch without net connections.
Surprisingly that worked without -Z offline but with -Z offline made it fail:

error: no matching package named `core-foundation` found
location searched: registry `https://github.com/rust-lang/crates.io-index`
required by package `cargo v0.30.0 (https://github.com/rust-lang/cargo?rev=9311f6d439e09da3ab918397a425be57da13f04a#9311f6d4)`
    ... which is depended on by `a v0.1.0 (file:///tmp/a)`
As a reminder, you're using offline mode (-Z offline) which can sometimes cause surprising resolution failures, if this error is too confusing you may with to retry without the offline flag.

Everything needed was already stored in the cache though.

@matklad matklad mentioned this issue Sep 12, 2018
@dwijnand dwijnand added the C-bug Category: bug label Dec 15, 2018
bors added a commit that referenced this issue Apr 2, 2019
Resolve: Be less strict while offline.

When offline, the resolver was requiring everything to be downloaded, even dependencies that are not used. This changes it so that the resolver can still resolve unavailable dependencies when offline. This pushes the failure to a later stage of Cargo where it attempts to download the dependency. This makes `-Z offline` work for target-cfg or optional dependencies that are not being used.

Fixes #6014.

This changes the error message significantly for the "unavailable" case (see test diff). I personally think the new error message is clearer, although it is shorter and provides less information. The old error message seemed large and scary, and was a little hard for me to grok. However, I'd be willing to look at tweaking the error behavior if not everyone agrees.
@bors bors closed this as completed in #6814 Apr 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants