From cb84547c88640ca253fc448d48c3f82cc1e5d98f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pascal=20Andr=C3=A9?= Date: Sun, 19 Apr 2026 00:34:49 +0200 Subject: [PATCH] fix(desktop): source shell rc before launching CLI (#332) Fixes #326 ## Summary - source the user's bash or zsh rc before launching the bundled CLI from Tauri - use `-l -i -c` for zsh so shell-managed Node runtimes are available in launcher-started sessions - fixes the reproduced Linux launcher case where the app exits with `CLI exited early: exit status: 127` while terminal launches work ## Validation - reproduced the failure with the released Tauri `v0.14.0` Linux binary - verified the patched binary succeeds under the same launcher-like environment - ran `cargo build` on the dev-based PR branch --- .../electron-app/electron/main/user-shell.ts | 21 +++---------------- .../tauri-app/src-tauri/src/cli_manager.rs | 7 +++++-- 2 files changed, 8 insertions(+), 20 deletions(-) diff --git a/packages/electron-app/electron/main/user-shell.ts b/packages/electron-app/electron/main/user-shell.ts index ee49e7c4..95640da8 100644 --- a/packages/electron-app/electron/main/user-shell.ts +++ b/packages/electron-app/electron/main/user-shell.ts @@ -20,24 +20,10 @@ function getDefaultShellPath(): string { return "/bin/bash" } -function wrapCommandForShell(command: string, shellPath: string): string { - const shellName = path.basename(shellPath) - - if (shellName.includes("bash")) { - return 'if [ -f ~/.bashrc ]; then source ~/.bashrc >/dev/null 2>&1; fi; ' + command - } - - if (shellName.includes("zsh")) { - return 'if [ -f ~/.zshrc ]; then source ~/.zshrc >/dev/null 2>&1; fi; ' + command - } - - return command -} - function buildShellArgs(shellPath: string): string[] { const shellName = path.basename(shellPath) - if (shellName.includes("zsh")) { - return ["-l", "-i", "-c"] + if (shellName.includes("zsh") || shellName.includes("bash")) { + return ["-i", "-l", "-c"] } return ["-l", "-c"] } @@ -59,12 +45,11 @@ export function buildUserShellCommand(userCommand: string): ShellCommand { } const shellPath = getDefaultShellPath() - const script = wrapCommandForShell(userCommand, shellPath) const args = buildShellArgs(shellPath) return { command: shellPath, - args: [...args, script], + args: [...args, userCommand], } } diff --git a/packages/tauri-app/src-tauri/src/cli_manager.rs b/packages/tauri-app/src-tauri/src/cli_manager.rs index 358523e3..613b1c2e 100644 --- a/packages/tauri-app/src-tauri/src/cli_manager.rs +++ b/packages/tauri-app/src-tauri/src/cli_manager.rs @@ -1288,8 +1288,11 @@ fn build_shell_args(shell: &str, command: &str) -> Vec { .unwrap_or("") .to_lowercase(); - let _ = shell_name; - vec!["-l".into(), "-c".into(), command.into()] + if shell_name.contains("zsh") || shell_name.contains("bash") { + vec!["-i".into(), "-l".into(), "-c".into(), command.into()] + } else { + vec!["-l".into(), "-c".into(), command.into()] + } } fn first_existing(paths: Vec>) -> Option {