gitbutlerapp/gitbutler · error

failed to open with app bundle identifier

Error message

failed to open {paths:?} with app bundle identifier '{}'

What it means

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.

Solutions

  1. Verify the app bundle identifier is correct and the app is installed (`mdls -name kMDItemCFBundleIdentifier -r /Applications/App.app`)
  2. Test manually: `open -b <bundle-id> <path>` to see the real error the suppressed stderr hides
  3. Check the path(s) passed exist and are absolute
  4. Fall back to opening with the default application by omitting the bundle id

Example fix

// before
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);
}
// after
let output = cmd.output()?;
if !output.status.success() {
    anyhow::bail!("failed to open {paths:?} with app bundle identifier '{}': {}",
        app.bundle_identifier, String::from_utf8_lossy(&output.stderr));
}
Defensive patterns

Strategy: fallback

Validate before calling

const ok = (await exec(`mdls -name kMDItemCFBundleIdentifier -r /Applications/YourApp.app`)) === bundleId;

Type guard

function hasBundleId(app: { bundle_identifier?: string }): app is { bundle_identifier: string } { return typeof app.bundle_identifier === 'string' && app.bundle_identifier.length > 0; }

Try / catch

try { await openInMacosApplication(path, app); } catch (e) { if (String(e).includes('failed to open')) { await openWithDefaultApp(path); } else { throw e; } }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "git command failed": what it means when a tool shells out to git and git exits non-zero — this error's family across 21 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/35bf78dc96506749. Report an issue: GitHub.

Appendix: 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 58e5313667)