{"record":{"id":"2bed226d03b3eaeb","repo":"gitbutlerapp/gitbutler","slug":"defaultterminalnotfound","errorCode":"DefaultTerminalNotFound","errorMessage":"'{app_name}' was not found - `open -Ra {app_name}` failed.","messagePattern":"'(.+?)' was not found - `open -Ra (.+?)` failed\\.","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/mod.rs","lineNumber":426,"sourceCode":"                .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                )\n                .context(but_error::Code::DefaultTerminalNotFound));\n            }\n            Ok(())\n        }\n\n        let open_with_path = |app_name: &str, alt_app_name: Option<&str>| {\n            ensure_app_installed(app_name)?;\n            let mut cmd = Command::new(\"open\");\n            cmd.arg(\"-a\").arg(app_name).arg(&path);\n            run_terminal_command(cmd, alt_app_name.unwrap_or(app_name), &path)\n        };\n\n        match terminal_id.as_str() {\n            // These terminals support `open -a <app> <path>` as folder handlers\n            \"terminal\" => open_with_path(\"Terminal\", None)?,\n            \"iterm2\" => open_with_path(\"iTerm\", Some(\"iTerm2\"))?,","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/mod.rs#L408-L444","documentation":"On macOS, open_in_terminal verifies that the selected terminal app exists by running `open -Ra <AppName>` before launching it. When that probe exits non-zero, macOS reports the application is not installed/registered with LaunchServices, so ensure_app_installed raises DefaultTerminalNotFound with this message. It exists so users get a clear 'install the app' error instead of a vague launch failure.","triggerScenarios":"Calling open_in_terminal (or the UI 'Open in terminal' action) with terminal_id like 'terminal', 'iterm2', 'warp', 'ghostty', 'hyper', 'alacritty-mac', or 'kitty' when the corresponding .app bundle is not installed or not visible to LaunchServices.","commonSituations":"User picks a terminal in GitButler Settings on a machine where that terminal was later uninstalled; app installed in a custom location not registered with LaunchServices; terminal only available via homebrew cask that was never linked as an .app; fresh macOS setup without iTerm2/Warp etc.","solutions":["Install the selected terminal application (e.g. via Homebrew: `brew install --cask iterm2`) or pick a different, installed terminal in Settings.","If the app is installed but not registered, open it once manually or run `lsregister -f /Applications/<App>.app` so `open -Ra` can find it.","Verify with `open -Ra <AppName>; echo $?` that macOS can see the app before re-triggering the action.","Reset the default terminal setting in the app's Settings to a terminal that is installed."],"exampleFix":"// before (Settings persisted a terminal that was uninstalled)\nopen_in_terminal(\"iterm2\", path) // -> DefaultTerminalNotFound\n// after\n// reinstall or re-register:\n// $ brew install --cask iterm2\nopen_in_terminal(\"iterm2\", path) // succeeds","handlingStrategy":"validation","validationCode":"import { invoke } from '@tauri-apps/api/core';\n// before opening, verify the app is visible to macOS\nconst res = await invoke('run_command', { program: 'open', args: ['-Ra', 'iTerm'] });\nif (res.code !== 0) throw new Error(`iTerm is not installed; pick another terminal in Settings`);","typeGuard":null,"tryCatchPattern":"try {\n  await openInTerminal('iterm2', path);\n} catch (e) {\n  if (String(e).includes('was not found')) {\n    showToast('Terminal not installed. Install it or choose another in Settings.');\n  } else throw e;\n}","preventionTips":["Only offer terminal options in Settings that a probe confirms are installed.","Re-run the availability probe when Settings loads or before each launch.","Fall back to Apple Terminal when the configured app is missing."],"tags":["macos","terminal","app-not-installed","open-command"],"backgroundTag":"command-not-found","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"}