Skip to content

Commit 3ed3497

Browse files
committed
Updating based on code review
1 parent ec5f78f commit 3ed3497

File tree

4 files changed

+22
-22
lines changed

4 files changed

+22
-22
lines changed

src/cargo/core/resolver/mod.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -889,8 +889,10 @@ fn activation_error(cx: &Context,
889889

890890
if let Some(config) = config {
891891
if config.cli_unstable().offline {
892-
msg.push_str("\nperhaps an error occurred because you are using \
893-
the offline mode");
892+
msg.push_str("\nAs a reminder, you're using offline mode (-Z offline) \
893+
which can sometimes cause surprising resolution failures, \
894+
if this error is too confusing you may with to retry \
895+
without the offline flag.");
894896
}
895897
}
896898

src/cargo/sources/git/source.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl<'cfg> Source for GitSource<'cfg> {
152152
let db_path = lock.parent().join("db").join(&self.ident);
153153

154154
if self.config.cli_unstable().offline && !db_path.exists() {
155-
bail!("can't checkout from '{}': you are in the offline mode", self.remote.url());
155+
bail!("can't checkout from '{}': you are in the offline mode (-Z offline)",
156+
self.remote.url());
156157
}
157158

158159
// Resolve our reference to an actual revision, and check if the

tests/build.rs

+15-17
Original file line numberDiff line numberDiff line change
@@ -897,13 +897,10 @@ fn cargo_compile_with_downloaded_dependency_with_offline() {
897897

898898
assert_that(p2.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
899899
execs().with_status(0)
900-
.with_stderr_does_not_contain("Updating registry")
901-
.with_stderr_does_not_contain("Downloading")
902900
.with_stderr(format!("\
903901
[COMPILING] present_dep v1.2.3
904-
[COMPILING] bar v0.1.0 ({url})
905-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
906-
url = p2.url())));
902+
[COMPILING] bar v0.1.0 ([..])
903+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]")));
907904

908905
}
909906

@@ -923,13 +920,14 @@ fn cargo_compile_offline_not_try_update() {
923920

924921
assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
925922
execs().with_status(101)
926-
.with_stderr_does_not_contain("Updating registry")
927-
.with_stderr_does_not_contain("Downloading")
928923
.with_stderr("\
929924
error: no matching package named `not_cached_dep` found (required by `bar`)
930925
location searched: registry `[..]`
931926
version required: ^1.2.5
932-
perhaps an error occurred because you are using the offline mode"));
927+
As a reminder, you're using offline mode (-Z offline) \
928+
which can sometimes cause surprising resolution failures, \
929+
if this error is too confusing you may with to retry \
930+
without the offline flag."));
933931
}
934932

935933
#[test]
@@ -987,16 +985,15 @@ fn main(){
987985
}")
988986
.build();
989987

990-
assert_that(p2.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
988+
assert_that(p2.cargo("run").masquerade_as_nightly_cargo().arg("-Zoffline"),
991989
execs().with_status(0)
992990
.with_stderr(format!("\
993991
[COMPILING] present_dep v1.2.3
994992
[COMPILING] foo v0.1.0 ({url})
995-
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]",
996-
url = p2.url())));
997-
998-
assert_that(process(&p2.bin("foo")),
999-
execs().with_status(0).with_stdout("1.2.3"));
993+
[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
994+
Running `[..]`", url = p2.url()))
995+
.with_stdout("1.2.3")
996+
);
1000997
}
1001998

1002999
#[test]
@@ -1033,13 +1030,14 @@ fn compile_offline_while_transitive_dep_not_cached() {
10331030

10341031
assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
10351032
execs().with_status(101)
1036-
.with_stderr_does_not_contain("Updating registry")
1037-
.with_stderr_does_not_contain("Downloading")
10381033
.with_stderr("\
10391034
error: no matching package named `bar` found (required by `foo`)
10401035
location searched: registry `[..]`
10411036
version required: = 1.0.0
1042-
perhaps an error occurred because you are using the offline mode"));
1037+
As a reminder, you're using offline mode (-Z offline) \
1038+
which can sometimes cause surprising resolution failures, \
1039+
if this error is too confusing you may with to retry \
1040+
without the offline flag."));
10431041
}
10441042

10451043
#[test]

tests/git.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,14 @@ fn cargo_compile_forbird_git_httpsrepo_offline() {
9797

9898
assert_that(p.cargo("build").masquerade_as_nightly_cargo().arg("-Zoffline"),
9999
execs().with_status(101).
100-
with_stderr_does_not_contain("[UPDATING] git repository [..]").
101100
with_stderr("\
102101
error: failed to load source for a dependency on `dep1`
103102
104103
Caused by:
105104
Unable to update https://github.com/some_user/dep1.git
106105
107106
Caused by:
108-
can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode"));
107+
can't checkout from 'https://github.com/some_user/dep1.git': you are in the offline mode (-Z offline)"));
109108
}
110109

111110

0 commit comments

Comments
 (0)