Skip to content

Commit 7690fc3

Browse files
committed
feat(dist): refine suggestions regarding manifest checksum mismatches
1 parent e16e606 commit 7690fc3

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -940,7 +940,7 @@ impl<'a> Cfg<'a> {
940940
}
941941
}
942942

943-
fn dist_root_server(process: &Process) -> Cow<'static, str> {
943+
pub(crate) fn dist_root_server(process: &Process) -> Cow<'static, str> {
944944
process
945945
.var("RUSTUP_DIST_SERVER")
946946
.ok()

src/dist/mod.rs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ use once_cell::sync::Lazy;
1010
use regex::Regex;
1111
use serde::{Deserialize, Serialize};
1212
use thiserror::Error as ThisError;
13-
use tracing::info;
13+
use tracing::{info, warn};
1414

1515
use crate::{
16-
config::Cfg, currentprocess::Process, errors::RustupError, toolchain::ToolchainName,
16+
config::{dist_root_server, Cfg},
17+
currentprocess::Process,
18+
errors::RustupError,
19+
toolchain::ToolchainName,
1720
utils::utils,
1821
};
1922

@@ -1166,9 +1169,23 @@ pub(crate) async fn dl_v2_manifest(
11661169
Ok(Some((manifest, manifest_hash)))
11671170
}
11681171
Err(any) => {
1169-
if let Some(RustupError::ChecksumFailed { .. }) = any.downcast_ref::<RustupError>() {
1170-
// Checksum failed - issue warning to try again later
1171-
info!("update not yet available, sorry! try again later")
1172+
if let Some(err @ RustupError::ChecksumFailed { .. }) =
1173+
any.downcast_ref::<RustupError>()
1174+
{
1175+
// Manifest checksum mismatched.
1176+
warn!("{err}");
1177+
1178+
let server = dist_root_server(download.process);
1179+
if server == DEFAULT_DIST_SERVER {
1180+
// This might indicate a transient state during an update
1181+
// on the official release server
1182+
// (see <https://github.com/rust-lang/rustup/issues/3390>)
1183+
info!("this is likely due to an ongoing update of the official release server, please try again later");
1184+
} else {
1185+
// This could also indicate a misconfiguration of a third-party release server
1186+
// (see <https://github.com/rust-lang/rustup/issues/3885>).
1187+
info!("this might indicate an issue with your third-party release server `{server}`");
1188+
}
11721189
}
11731190
Err(any)
11741191
}

tests/suite/cli_v2.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -358,10 +358,7 @@ async fn bad_sha_on_manifest() {
358358
rustup::utils::raw::write_file(&sha_file, &sha_str).unwrap();
359359
// We fail because the sha is bad, but we should emit the special message to that effect.
360360
cx.config
361-
.expect_err(
362-
&["rustup", "default", "nightly"],
363-
"update not yet available",
364-
)
361+
.expect_err(&["rustup", "default", "nightly"], "please try again later")
365362
.await;
366363
}
367364

0 commit comments

Comments
 (0)