Skip to content

Commit 2f35b63

Browse files
committed
fix(registry): Respect --frozen like --offline
1 parent e115c3c commit 2f35b63

File tree

4 files changed

+12
-25
lines changed

4 files changed

+12
-25
lines changed

src/cargo/sources/registry/http_remote.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ impl<'gctx> HttpRegistry<'gctx> {
376376
} else if self.gctx.cli_unstable().no_index_update {
377377
trace!("using local {} in no_index_update mode", path.display());
378378
true
379-
} else if self.gctx.offline() {
379+
} else if !self.gctx.network_allowed() {
380380
trace!("using local {} in offline mode", path.display());
381381
true
382382
} else if self.fresh.contains(path) {
@@ -511,7 +511,7 @@ impl<'gctx> RegistryData for HttpRegistry<'gctx> {
511511
return Poll::Ready(Ok(LoadResponse::NotFound));
512512
}
513513

514-
if self.gctx.offline() || self.gctx.cli_unstable().no_index_update {
514+
if !self.gctx.network_allowed() || self.gctx.cli_unstable().no_index_update {
515515
// Return NotFound in offline mode when the file doesn't exist in the cache.
516516
// If this results in resolution failure, the resolver will suggest
517517
// removing the --offline flag.

src/cargo/sources/registry/index/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ impl<'gctx> RegistryIndex<'gctx> {
482482
load: &mut dyn RegistryData,
483483
f: &mut dyn FnMut(IndexSummary),
484484
) -> Poll<CargoResult<()>> {
485-
if self.gctx.offline() {
485+
if !self.gctx.network_allowed() {
486486
// This should only return `Poll::Ready(Ok(()))` if there is at least 1 match.
487487
//
488488
// If there are 0 matches it should fall through and try again with online.

src/cargo/sources/registry/remote.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ impl<'gctx> RegistryData for RemoteRegistry<'gctx> {
345345
}
346346
self.mark_updated();
347347

348-
if self.gctx.offline() {
348+
if !self.gctx.network_allowed() {
349349
return Ok(());
350350
}
351351
if self.gctx.cli_unstable().no_index_update {

tests/testsuite/registry.rs

+8-21
Original file line numberDiff line numberDiff line change
@@ -2431,14 +2431,10 @@ fn disallow_network_http() {
24312431
p.cargo("check --frozen")
24322432
.with_status(101)
24332433
.with_stderr_data(str![[r#"
2434-
[UPDATING] `dummy-registry` index
2435-
[ERROR] failed to get `foo` as a dependency of package `bar v0.5.0 ([ROOT]/foo)`
2436-
2437-
Caused by:
2438-
failed to query replaced source registry `crates-io`
2439-
2440-
Caused by:
2441-
attempting to make an HTTP request, but --frozen was specified
2434+
[ERROR] no matching package named `foo` found
2435+
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
2436+
required by package `bar v0.5.0 ([ROOT]/foo)`
2437+
As a reminder, you're using offline mode (--frozen) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without `--frozen`.
24422438
24432439
"#]])
24442440
.run();
@@ -2467,19 +2463,10 @@ fn disallow_network_git() {
24672463
p.cargo("check --frozen")
24682464
.with_status(101)
24692465
.with_stderr_data(str![[r#"
2470-
[ERROR] failed to get `foo` as a dependency of package `bar v0.5.0 ([ROOT]/foo)`
2471-
2472-
Caused by:
2473-
failed to load source for dependency `foo`
2474-
2475-
Caused by:
2476-
Unable to update registry `crates-io`
2477-
2478-
Caused by:
2479-
failed to update replaced source registry `crates-io`
2480-
2481-
Caused by:
2482-
attempting to make an HTTP request, but --frozen was specified
2466+
[ERROR] no matching package named `foo` found
2467+
location searched: `dummy-registry` index (which is replacing registry `crates-io`)
2468+
required by package `bar v0.5.0 ([ROOT]/foo)`
2469+
As a reminder, you're using offline mode (--frozen) which can sometimes cause surprising resolution failures, if this error is too confusing you may wish to retry without `--frozen`.
24832470
24842471
"#]])
24852472
.run();

0 commit comments

Comments
 (0)