{"record":{"id":"8a40cbaaa2438107","repo":"gitbutlerapp/gitbutler","slug":"terminal-name-exited-with-non-zero-status-stat","errorCode":null,"errorMessage":"{terminal_name} exited with non-zero status: {status_code}","messagePattern":"(.+?) exited with non-zero status: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/mod.rs","lineNumber":410,"sourceCode":"            use bstr::ByteSlice;\n\n            tracing::info!(?cmd, \"terminal command\");\n            let output = cmd\n                .output()\n                .with_context(|| format!(\"Failed to launch {terminal_name} at '{path}'\"))?;\n\n            if output.status.success() {\n                return Ok(());\n            }\n\n            let stderr = output.stderr.to_str_lossy();\n            let stderr = stderr.trim();\n            let status_code = output\n                .status\n                .code()\n                .map_or(\"unknown\".to_string(), |c| c.to_string());\n            if stderr.is_empty() {\n                bail!(\"{terminal_name} exited with non-zero status: {status_code}\",);\n            } else {\n                bail!(\"Failed to open {terminal_name} ({status_code}): {stderr}\");\n            }\n        }\n\n        /// Check if a macOS application is installed using `open -Ra`.\n        fn ensure_app_installed(app_name: &str) -> Result<()> {\n            let status = Command::new(\"open\")\n                .arg(\"-Ra\")\n                .arg(app_name)\n                .stdout(Stdio::null())\n                .stderr(Stdio::null())\n                .status()\n                .context(\"Failed to run 'open -Ra' to check application availability\")?;\n            if !status.success() {\n                return Err(anyhow::anyhow!(\n                    \"'{app_name}' was not found - `open -Ra {app_name}` failed.\"\n                )","sourceCodeStart":392,"sourceCodeEnd":428,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/mod.rs#L392-L428","documentation":"run_terminal_command() runs a terminal emulator's launch command and captures output. If the command exits with a non-zero status and stderr is empty, there is nothing more specific to report, so it bails naming the terminal and its exit status code. It signals the terminal emulator rejected or failed the launch without producing a diagnostic.","triggerScenarios":"open_in_terminal launches a configured terminal (e.g. WezTerm, GNOME Terminal, iTerm) whose process exits non-zero without writing to stderr.","commonSituations":"Terminal binary present but crashing on startup, bad terminal config file, sandbox/display issues (no DISPLAY/Wayland), or terminal exiting immediately due to invalid --cwd arguments.","solutions":["Run the same terminal command manually to see its exit behavior","Fix the terminal emulator's configuration or environment (DISPLAY, Wayland socket)","Verify the cwd passed to open_in_terminal is accessible from the terminal process","Update or reinstall the terminal emulator"],"exampleFix":"// before\nopen_in_terminal(\"wezterm\", broken_path) // exits non-zero, silent\n// after\nopen_in_terminal(\"wezterm\", \"/home/user/project\") // valid dir","handlingStrategy":"try-catch","validationCode":"// check the terminal binary is launchable before delegating\nif which::which(terminal::terminal_binary(terminal_id)).is_err() {\n    return Err(anyhow!(\"terminal {terminal_id} not installed\"));\n}","typeGuard":null,"tryCatchPattern":"match open_in_terminal(terminal_id, &path) {\n    Err(e) if e.to_string().contains(\"exited with non-zero status\") => {\n        eprintln!(\"{terminal_id} failed silently ({e}); try running it manually\");\n    }\n    r => r?,\n}","preventionTips":["Keep terminal emulator configs valid; test launches after terminal upgrades","Ensure DISPLAY/Wayland env is available for GUI terminals","Validate the cwd passed to open_in_terminal exists and is readable"],"tags":["terminal","process","exit-code"],"backgroundTag":"command-failed-nonzero-status","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}