{"record":{"id":"35bf78dc96506749","repo":"gitbutlerapp/gitbutler","slug":"failed-to-open-paths-with-app-bundle-identifie","errorCode":null,"errorMessage":"failed to open {paths:?} with app bundle identifier '{}'","messagePattern":"failed to open (.+?) with app bundle identifier '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but-api/src/open/program.rs","lineNumber":659,"sourceCode":"    }\n}\n\n#[cfg(target_os = \"macos\")]\nfn open_macos_application_via_open(\n    app: &MacosApplication,\n    paths: &NonEmpty<PathBuf>,\n) -> anyhow::Result<()> {\n    let mut cmd = Command::new(\"/usr/bin/open\");\n    cmd.arg(\"-b\").arg(&app.bundle_identifier);\n\n    for path in paths {\n        cmd.arg(path);\n    }\n\n    let status = cmd.stdout(Stdio::null()).stderr(Stdio::null()).status()?;\n\n    if !status.success() {\n        anyhow::bail!(\n            \"failed to open {paths:?} with app bundle identifier '{}'\",\n            app.bundle_identifier\n        );\n    }\n\n    Ok(())\n}\n\n/// A serializable form of [`ProgramSpec`] for user defined programs.\n#[derive(Debug, Deserialize)]\n#[serde(rename_all = \"camelCase\")]\npub struct UserDefinedProgramSpec {\n    /// Identifier used to refer to the program.\n    ///\n    /// If left empty, the ID is derived from [`Self::name`] instead.\n    pub id: Option<String>,\n    /// The display name of the program.\n    pub name: Option<String>,","sourceCodeStart":641,"sourceCodeEnd":677,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but-api/src/open/program.rs#L641-L677","documentation":"This error is thrown when the macOS `open` command exits with a non-zero status after being asked to open one or more paths with a specific application identified by its bundle identifier. The underlying `open` invocation's stdout/stderr are suppressed, so the actual reason is hidden and only the bundle id is reported.","triggerScenarios":"Calling open_in_macos_application -> open_macos_application_via_open with an app bundle identifier that is not installed/enabled, a path that `open` cannot handle, or when the system `open` command fails for any reason (bad -b argument, sandboxing, malformed path).","commonSituations":"Typos in the bundle identifier (e.g. 'com.apple.Safari' vs 'com.apple.Safai'), app uninstalled or not in Spotlight index, opening files the target app cannot handle, or running in an environment where launching GUI apps fails.","solutions":["Verify the app bundle identifier is correct and the app is installed (`mdls -name kMDItemCFBundleIdentifier -r /Applications/App.app`)","Test manually: `open -b <bundle-id> <path>` to see the real error the suppressed stderr hides","Check the path(s) passed exist and are absolute","Fall back to opening with the default application by omitting the bundle id"],"exampleFix":"// before\nlet status = cmd.stdout(Stdio::null()).stderr(Stdio::null()).status()?;\nif !status.success() {\n    anyhow::bail!(\"failed to open {paths:?} with app bundle identifier '{}'\", app.bundle_identifier);\n}\n// after\nlet output = cmd.output()?;\nif !output.status.success() {\n    anyhow::bail!(\"failed to open {paths:?} with app bundle identifier '{}': {}\",\n        app.bundle_identifier, String::from_utf8_lossy(&output.stderr));\n}","handlingStrategy":"fallback","validationCode":"const ok = (await exec(`mdls -name kMDItemCFBundleIdentifier -r /Applications/YourApp.app`)) === bundleId;","typeGuard":"function hasBundleId(app: { bundle_identifier?: string }): app is { bundle_identifier: string } { return typeof app.bundle_identifier === 'string' && app.bundle_identifier.length > 0; }","tryCatchPattern":"try { await openInMacosApplication(path, app); } catch (e) { if (String(e).includes('failed to open')) { await openWithDefaultApp(path); } else { throw e; } }","preventionTips":["Validate bundle identifiers against installed apps before calling","Test `open -b <id> <path>` manually when integration fails","Keep paths absolute and existing","Capture `open` stderr when debugging instead of nulling it"],"tags":["macos","open-command","process-spawn"],"backgroundTag":"git-command-failed","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"}