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

Add some help with updating the registry in offline mode. #6871

Merged
merged 4 commits into from Apr 29, 2019

Conversation

ehuss
Copy link
Contributor

@ehuss ehuss commented Apr 24, 2019

This includes the following:

  • Move offline tests to a dedicated file.

  • If an index has never been downloaded, and -Z offline is used, provide a suggestion to run without -Z offline.

  • If an index needs to be updated, and the network appears to be down, suggest running with -Z offline. (removed this)

  • The offline_resolve_optional_fail test is added to show that resolver errors are still possible (though hopefully rare!).

@ehuss
Copy link
Contributor Author

ehuss commented Apr 24, 2019

This is an attempt to improve some error message, but I'm on the fence if it actually does that, so I figured I'd post this for comments.

I think repo.is_empty() should be a reliable way to determine if the repository has never been fetched, but I'm not certain.

I'm not sure if the offline && is_empty() check might give a false positive for the error. I can't think of any, though.

The maybe_spurious check may have false positives.

I'm not sure if the wording is clear.

@rust-highfive
Copy link

r? @nrc

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 24, 2019
@ehuss ehuss force-pushed the offline-spurious-suggestion branch from 42e95c2 to f876910 Compare April 24, 2019 01:02
if let Err(e) = result {
let extra = if maybe_spurious(&e) && nightly_features_allowed() && !repo.is_empty()? {
"\nIf the network is unavailable, consider running with the -Zoffline \
flag to run in offline mode."
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This warning I'm somewhat wary about because it feels a little aggressive about mentioning -Zoffline. We're already pretty fast-and-loose with what we interpret as spurious network error (we're rarely sure that it's a spurious error, it's just a random bucket of things that are all somewhat network related).

I'm personally wary of CI tools that make suggestions which often don't end up being applicable as well because it can be a frustrating experience. Ideally we'd recognize a spurious error, actually run resolution in offline mode, realize it works, and only then actually emit an appropriate error. That seems a bit heavy handed and a bit far fetched though.

Do you think though that if we don't have this sort of an error message then -Zoffline will be difficult to discover?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea, this is only for discoverability. Should I just remove this, or would it be worthwhile to emit a warning and see if it can succeed to resolve? I lean towards just removing it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also fires for cargo install which will give a bad suggestion, cargo install foo -Z offline will fail, so I think the risk of a bad suggestion is a little too high.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm those are good points yeah. I'm fine with landing without this and we can sort of see over time whether we feel that we need to improve the error messages for offline.

Run `cargo fetch` to download the registry index and all \
of a project's dependencies before going offline.",
self.source_id
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a comment here that we're explicitly switching the Ok to an Err because if we're updating the index we're guaranteed to require at leats one crate and since the index is empty it's guaranteed to have zero crates, therefore we're trying to give a better error message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this suggestion is also a little sketchy. If you run cargo install foo for the first time, and the index is unavailable, it suggests running cargo fetch which will definitely not work. Maybe it is not worth it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point yeah, but I think that could be fixed by tweaking the error message? It could mention that you should try running with out --offline or otherwise run cargo fetch sooner perhaps?

@ehuss ehuss mentioned this pull request Apr 25, 2019
This makes two changes:

- If an index has never been downloaded, and `-Z offline` is used, provide a
  suggestion to run without `-Z offline`.

- If an index needs to be updated, and the network appears to be down, suggest
  running with `-Z offline`.
This is just too likely to be a false positive, or otherwise a bad suggestion.
@ehuss ehuss force-pushed the offline-spurious-suggestion branch from f876910 to c6fad3a Compare April 29, 2019 03:04
@ehuss
Copy link
Contributor Author

ehuss commented Apr 29, 2019

OK, I reverted the spurious error, and tweaked the text of the other one.

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Collaborator

bors commented Apr 29, 2019

📌 Commit c6fad3a has been approved by alexcrichton

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 29, 2019
@bors
Copy link
Collaborator

bors commented Apr 29, 2019

⌛ Testing commit c6fad3a with merge 2de6c3e...

bors added a commit that referenced this pull request Apr 29, 2019
 Add some help with updating the registry in offline mode.

This includes the following:

- Move offline tests to a dedicated file.

- If an index has never been downloaded, and `-Z offline` is used, provide a suggestion to run without `-Z offline`.

- ~~If an index needs to be updated, and the network appears to be down, suggest running with `-Z offline`.~~ (removed this)

- The `offline_resolve_optional_fail` test is added to show that resolver errors are still possible (though hopefully rare!).
@bors
Copy link
Collaborator

bors commented Apr 29, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: alexcrichton
Pushing 2de6c3e to master...

@bors bors merged commit c6fad3a into rust-lang:master Apr 29, 2019
bors added a commit that referenced this pull request Dec 4, 2019
Remove --offline empty index error.

This reverts the error added in #6871 which attempts to provide a "nicer" error message if `--offline` is used with an empty index. I was concerned about false positives, and sure enough someone found one. If all deps are patched, it is OK for the index to be empty, because the resolver will just use the patched entries.

I considered trying to move the error to another location, but I think it would require significant changes to the registry API (which is already hard to follow). I figure the "not found" error message is good enough with the "don't use --offline" hint.

Closes #7582
@ehuss ehuss added this to the 1.36.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants