From b6ca8885ffba26f83ec2ff2d8dd0d5659ac531d7 Mon Sep 17 00:00:00 2001 From: Ananth <136650032+KekmaTime@users.noreply.github.com> Date: Tue, 12 Dec 2023 03:36:43 +0530 Subject: [PATCH] feat(cli): improve error message with invalid target for `build` (#8321) --- tooling/cli/src/interface/rust.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/tooling/cli/src/interface/rust.rs b/tooling/cli/src/interface/rust.rs index 3ba6b0166..1d2829c3d 100644 --- a/tooling/cli/src/interface/rust.rs +++ b/tooling/cli/src/interface/rust.rs @@ -228,8 +228,16 @@ impl Interface for Rust { self.app_settings.target_triple.clone(), ); - let mut s = self.app_settings.target_triple.split('-'); - let (arch, _, host) = (s.next().unwrap(), s.next().unwrap(), s.next().unwrap()); + let target_triple = &self.app_settings.target_triple; + let target_components: Vec<&str> = target_triple.split('-').collect(); + let (arch, host) = match target_components.as_slice() { + [arch, _, host] => (*arch, *host), + _ => { + log::warn!("Invalid target triple: {}", target_triple); + return env; + } + }; + env.insert( "TAURI_ENV_ARCH", match arch {