Skip to content

Commit c6fad3a

Browse files
committed
Tweak the error message when updating an empty registry while offline.
1 parent 0c4fb75 commit c6fad3a

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/cargo/sources/registry/remote.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,14 @@ impl<'cfg> RegistryData for RemoteRegistry<'cfg> {
177177
fn update_index(&mut self) -> CargoResult<()> {
178178
if self.config.cli_unstable().offline {
179179
if self.repo()?.is_empty()? {
180+
// An empty repository is guaranteed to fail, since hitting
181+
// this path means we need at least one crate. This is an
182+
// attempt to provide a better error message other than "no
183+
// matching package named …".
180184
failure::bail!(
181185
"unable to fetch {} in offline mode\n\
182-
Run `cargo fetch` to download the registry index and all \
183-
of a project's dependencies before going offline.",
186+
Try running without the offline flag, or try running \
187+
`cargo fetch` within your project directory before going offline.",
184188
self.source_id
185189
);
186190
}

tests/testsuite/offline.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,8 @@ Caused by:
178178
179179
Caused by:
180180
unable to fetch registry `https://github.com/rust-lang/crates.io-index` in offline mode
181-
Run `cargo fetch` to download the registry index and all of a project's dependencies before going offline.
181+
Try running without the offline flag, or try running `cargo fetch` within your \
182+
project directory before going offline.
182183
",
183184
)
184185
.run();

0 commit comments

Comments
 (0)