From a75e3b1bcd198bfd1b2ce4670d9996d938a8ea99 Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Sat, 28 Feb 2026 10:04:00 -0300 Subject: [PATCH] feat(cli): include stderr in command error --- .changes/include-stderr-error.md | 7 +++++++ crates/tauri-bundler/src/utils/mod.rs | 7 ++++--- crates/tauri-cli/src/lib.rs | 8 ++++---- 3 files changed, 15 insertions(+), 7 deletions(-) create mode 100644 .changes/include-stderr-error.md diff --git a/.changes/include-stderr-error.md b/.changes/include-stderr-error.md new file mode 100644 index 000000000..45dae762c --- /dev/null +++ b/.changes/include-stderr-error.md @@ -0,0 +1,7 @@ +--- +"@tauri-apps/cli": patch:enhance +"tauri-cli": patch:enhance +"tauri-bundler": patch:enhance +--- + +When a captured command fails, include its stderr in the error message. diff --git a/crates/tauri-bundler/src/utils/mod.rs b/crates/tauri-bundler/src/utils/mod.rs index 87f39c4da..21c3843bb 100644 --- a/crates/tauri-bundler/src/utils/mod.rs +++ b/crates/tauri-bundler/src/utils/mod.rs @@ -102,9 +102,10 @@ impl CommandExt for Command { if output.status.success() { Ok(output) } else { - Err(crate::Error::GenericError(format!( - "failed to run {program}" - ))) + Err(crate::Error::CommandFailed { + command: program, + error: std::io::Error::other(String::from_utf8_lossy(&output.stderr).to_string()), + }) } } } diff --git a/crates/tauri-cli/src/lib.rs b/crates/tauri-cli/src/lib.rs index 186ef0ef8..9f301a08b 100644 --- a/crates/tauri-cli/src/lib.rs +++ b/crates/tauri-cli/src/lib.rs @@ -411,10 +411,10 @@ impl CommandExt for Command { if output.status.success() { Ok(output) } else { - crate::error::bail!( - "failed to run command `{cmdline}`: command exited with status code {}", - output.status.code().unwrap_or(-1) - ); + Err(crate::error::Error::CommandFailed { + command: cmdline, + error: std::io::Error::other(String::from_utf8_lossy(&output.stderr).to_string()), + }) } } }