Skip to content

Commit 8ae5472

Browse files
committed
Remove eager fail for update --offline
1 parent 2bdac84 commit 8ae5472

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

src/cargo/ops/cargo_generate_lockfile.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,6 @@ pub fn update_lockfile(ws: &Workspace<'_>, opts: &UpdateOptions<'_>) -> CargoRes
4444
anyhow::bail!("you can't generate a lockfile for an empty workspace.")
4545
}
4646

47-
if opts.config.offline() && opts.precise.is_none() {
48-
anyhow::bail!("you can't update in the offline mode without precise packages");
49-
}
50-
5147
// Updates often require a lot of modifications to the registry, so ensure
5248
// that we're synchronized against other Cargos.
5349
let _lock = ws.config().acquire_package_cache_lock()?;

tests/testsuite/offline.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@ fn offline_with_all_patched() {
564564
}
565565

566566
#[cargo_test]
567-
fn offline_precise_update() {
567+
fn offline_update() {
568568
// Cache a few versions to update against
569569
let p = project().file("src/lib.rs", "").build();
570570
let versions = ["1.2.3", "1.2.5", "1.2.9"];
@@ -648,10 +648,20 @@ fn main(){
648648
",
649649
)
650650
.run();
651-
p2.rename_run("foo", "with_1_2_9")
651+
p2.rename_run("foo", "with_1_2_3")
652652
.with_stdout("1.2.3")
653653
.run();
654654

655+
// Offline update should only print package details and not index updating
656+
p2.cargo("update --offline")
657+
.with_status(0)
658+
.with_stderr(
659+
"\
660+
[UPDATING] present_dep v1.2.3 -> v1.2.9
661+
",
662+
)
663+
.run();
664+
655665
// No v1.2.8 loaded into the cache so expect failure.
656666
p2.cargo("update -p present_dep --precise 1.2.8 --offline")
657667
.with_status(101)

0 commit comments

Comments
 (0)