gitbutlerapp/gitbutler · error
failed to open {paths:?} with app bundle identifier '{}'
Error message
failed to open {paths:?} with app bundle identifier '{}' What it means
Raised by open_macos_application_via_open (crates/but-api/src/open/program.rs:645), the fallback used when a macOS app has no CLI wrapper: it runs /usr/bin/open -b <bundle_identifier> <paths>. This error means the process ran but exited non-zero, which happens when no installed app registers that bundle identifier or the app cannot accept the given documents. stdout/stderr are redirected to null, so this message is the only diagnostic the caller receives.
Source
Thrown at crates/but-api/src/open/program.rs:659
}
}
#[cfg(target_os = "macos")]
fn open_macos_application_via_open(
app: &MacosApplication,
paths: &NonEmpty<PathBuf>,
) -> anyhow::Result<()> {
let mut cmd = Command::new("/usr/bin/open");
cmd.arg("-b").arg(&app.bundle_identifier);
for path in paths {
cmd.arg(path);
}
let status = cmd.stdout(Stdio::null()).stderr(Stdio::null()).status()?;
if !status.success() {
anyhow::bail!(
"failed to open {paths:?} with app bundle identifier '{}'",
app.bundle_identifier
);
}
Ok(())
}
/// A serializable form of [`ProgramSpec`] for user defined programs.
#[derive(Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct UserDefinedProgramSpec {
/// Identifier used to refer to the program.
///
/// If left empty, the ID is derived from [`Self::name`] instead.
pub id: Option<String>,
/// The display name of the program.
pub name: Option<String>,View on GitHub (pinned to 2497b8007a)
Solutions
- Verify the identifier is registered: mdfind "kMDItemCFBundleIdentifier == '<bundle_id>'" or osascript -e 'id of app "Safari"'.
- Run /usr/bin/open -b '<bundle_id>' <one-file> manually with stderr visible to get the real exit reason.
- Fix the ProgramSpec's bundle identifier or reinstall the target app.
- If only certain documents fail, open them with the default handler instead.
Example fix
// before: only the generic error survives
open_macos_application_via_open(&app, &paths)?;
// after: preflight bundle-id registration
let out = std::process::Command::new("mdfind")
.arg(format!("kMDItemCFBundleIdentifier == '{}'", app.bundle_identifier))
.output()?;
if String::from_utf8_lossy(&out.stdout).trim().is_empty() {
anyhow::bail!("no installed app registers bundle id '{}'", app.bundle_identifier);
}
open_macos_application_via_open(&app, &paths)?; Defensive patterns
Strategy: try-catch
Validate before calling
const registered = execSync(
`mdfind "kMDItemCFBundleIdentifier == '${bundleId}'"`
).toString().trim();
if (!registered) {
throw new Error(`no installed app registers bundle id '${bundleId}'`);
} Try / catch
try {
await openWithProgram(app, paths);
} catch (e) {
if (String(e.message).includes('app bundle identifier')) {
await openWithDefaultHandler(paths); // fallback: OS default app
return;
}
throw e;
} Prevention
- Validate bundle ids with mdfind when the user saves a custom program.
- Do not discard /usr/bin/open's stderr in wrappers — capture it for diagnostics.
- Smoke-test custom programs with one representative file after every app install or update.
When it happens
Trigger: Opening a file with a MacosApplication whose bundle_identifier is misspelled or whose app is not installed; passing documents the target app refuses; this path is taken when resolve_cli_wrapper_abspath() fails (no CLI wrapper like 'code' exists for the app).
Common situations: User-defined programs with stale bundle ids after uninstall/update; Homebrew cask installs registering a different bundle id; app still quarantined on a fresh install so LaunchServices has not registered it.
Related errors
- CliInstallCancelled
- osascript exited with status {}
- DefaultTerminalNotFound
- programs was just checked to be non-empty
AI-assisted analysis of gitbutlerapp/gitbutler@2497b8007a (2026-08-17).
Data as JSON: /api/errors/35bf78dc96506749.
Report an issue: GitHub.