From c9cd77a124aee017757be679eae1841046c1baee Mon Sep 17 00:00:00 2001 From: rami3l Date: Sat, 3 Aug 2024 14:28:32 +0800 Subject: [PATCH] fix(config): call `warn_if_host_is_incompatible()` in `ensure_install()` --- src/config.rs | 13 +++++++++++-- tests/suite/cli_rustup.rs | 13 +++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index abf859210d3..5fa59b49573 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,8 +11,11 @@ use tokio_stream::StreamExt; use tracing::trace; use crate::{ - cli::self_update::SelfUpdateMode, - dist::{self, download::DownloadCfg, temp, PartialToolchainDesc, Profile, ToolchainDesc}, + cli::{common, self_update::SelfUpdateMode}, + dist::{ + self, download::DownloadCfg, temp, PartialToolchainDesc, Profile, TargetTriple, + ToolchainDesc, + }, errors::RustupError, fallback_settings::FallbackSettings, install::UpdateStatus, @@ -788,6 +791,12 @@ impl<'a> Cfg<'a> { profile: Option, verbose: bool, ) -> Result<(UpdateStatus, Toolchain<'_>)> { + common::warn_if_host_is_incompatible( + toolchain, + &TargetTriple::from_host_or_build(self.process), + &toolchain.target, + false, + )?; if verbose { (self.notify_handler)(Notification::LookingForToolchain(toolchain)); } diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 6e82ede94cc..5ae0e97385a 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -2725,6 +2725,19 @@ warn: If you meant to build software to target that platform, perhaps try `rustu ).await; } +#[tokio::test] +async fn warn_on_unmatch_build_default() { + let cx = CliTestContext::new(Scenario::MultiHost).await; + let arch = clitools::MULTI_ARCH1; + cx.config.expect_stderr_ok( + &["rustup", "default", &format!("nightly-{arch}")], + &format!( + r"warn: toolchain 'nightly-{arch}' may not be able to run on this system. +warn: If you meant to build software to target that platform, perhaps try `rustup target add {arch}` instead?", + ), + ).await; +} + #[tokio::test] async fn dont_warn_on_partial_build() { let cx = CliTestContext::new(Scenario::SimpleV2).await;