Skip to content

Commit

Permalink
fix(config): call warn_if_host_is_incompatible() in ensure_install()
Browse files Browse the repository at this point in the history
  • Loading branch information
rami3l committed Aug 5, 2024
1 parent 32e3338 commit ed2bfde
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -788,6 +791,12 @@ impl<'a> Cfg<'a> {
profile: Option<Profile>,
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));
}
Expand Down
13 changes: 13 additions & 0 deletions tests/suite/cli_rustup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ed2bfde

Please sign in to comment.