{"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":"anyhow::Error","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/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but-api/src/open/mod.rs#L392-L428","documentation":"macOS branch of open_in_terminal: run_terminal_command (crates/but-api/src/open/mod.rs:391-414) executes the terminal launch command (usually `open -a <App> <path>`, or `wezterm start --cwd`) and waits for it. A non-zero exit with empty stderr produces this generic status message including the exit code.","triggerScenarios":"`open -a` fails even though the earlier `open -Ra` availability probe succeeded: corrupted or quarantined app bundle, macOS refusing the launch, or a path argument the app rejects. Also the wezterm CLI exiting non-zero without writing to stderr.","commonSituations":"Terminal app updated/moved while GitButler runs; app translocation/quarantine after download; Gatekeeper prompt dismissed; path containing characters the app mishandles.","solutions":["Run the same launch manually in Terminal (e.g. `open -a Ghostty /path/to/repo`) to surface the real failure","Reinstall the terminal app or clear quarantine: xattr -dr com.apple.quarantine /Applications/<App>.app","Confirm the passed path exists and is a directory, then try another terminal selected in Settings","For wezterm, run `wezterm start --cwd /path` by hand to check its config"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await client.openInTerminal(terminalId, repoPath);\n} catch (e) {\n  const msg = String(e);\n  if (msg.includes('exited with non-zero status')) {\n    // show 'terminal failed to launch, pick another in Settings' + suggest\n    // running `open -a <App> <path>` manually to see the cause\n  } else throw e;\n}","preventionTips":["Verify the terminal app launches normally before selecting it in Settings","Clear quarantine attributes on downloaded terminal apps","Always pass an existing directory path to openInTerminal"],"tags":["terminal","macos","process-launch","open-command","rust"],"backgroundTag":"terminal-launch-failed","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}