gitbutlerapp/gitbutler · error · anyhow::Error

Could not find application for '{}'

Error message

Could not find application for '{}'

What it means

MacosApplication::find_app_directory asks macOS Launch Services (NSWorkspace::URLForApplicationWithBundleIdentifier) for the app registered under bundle_identifier and got back None. That means no installed application on this machine currently claims that bundle id, so GitButler cannot locate the .app directory needed to resolve the CLI wrapper or launch the app.

Source

Thrown at crates/but-api/src/open/program.rs:608

    fn resolve_cli_wrapper_abspath(&self) -> anyhow::Result<PathBuf> {
        let app_dir_path = self.find_app_directory()?;
        let cli_wrapper_path = self.cli_wrapper_path.as_deref().ok_or_else(|| {
            anyhow::anyhow!("No CLI wrapper configured for {}", self.bundle_identifier)
        })?;
        Ok(app_dir_path.join(cli_wrapper_path))
    }

    #[cfg(target_os = "macos")]
    fn find_app_directory(&self) -> anyhow::Result<PathBuf> {
        use objc2_app_kit::NSWorkspace;
        use objc2_foundation::NSString;

        let workspace = NSWorkspace::sharedWorkspace();
        let bundle_identifier = NSString::from_str(&self.bundle_identifier);
        let app_url = workspace
            .URLForApplicationWithBundleIdentifier(&bundle_identifier)
            .ok_or_else(|| {
                anyhow::anyhow!(
                    "Could not find application for '{}'",
                    self.bundle_identifier
                )
            })?;

        app_url.to_file_path().ok_or_else(|| {
            anyhow::anyhow!(
                "Could not resolve application path for '{}'",
                self.bundle_identifier
            )
        })
    }
}

#[cfg(target_os = "macos")]
fn open_in_macos_application(
    app: &MacosApplication,
    cli_arg_supplier: &CliArgumentSupplier,

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Install the application that owns the bundle identifier on this Mac
  2. Verify the installed app's real bundle id with `mdls -name kMDItemCFBundleIdentifier /Applications/MyApp.app` and fix the configured bundle_identifier to match exactly
  3. If the app is installed but still not found, re-register it (launch it once, or run `lsregister -f /Applications/MyApp.app`) so Launch Services refreshes
Defensive patterns

Strategy: fallback

Validate before calling

// Rust: ask Launch Services before entering the flow (macOS only)
#[cfg(target_os = "macos")]
fn app_installed(bundle_id: &str) -> bool {
    use objc2_app_kit::NSWorkspace;
    use objc2_foundation::NSString;
    NSWorkspace::sharedWorkspace()
        .URLForApplicationWithBundleIdentifier(&NSString::from_str(bundle_id))
        .is_some()
}

Try / catch

match open_in_macos_application(&app, &args, spec) {
    Err(err) if err.to_string().contains("Could not find application") => {
        // fall back to `open -b <bundle-id>` or prompt the user to install the app
    }
    result => result,
}

Prevention

When it happens

Trigger: Resolving an application directory for a bundle identifier that Launch Services does not know: the target app was never installed on this Mac, was uninstalled, or the bundle_identifier string in the configuration does not match the app's real CFBundleIdentifier.

Common situations: Developer or user machine without the target app installed; a stale or typo'd bundle identifier after an app rebrand or config edit; an app installed from a DMG that Launch Services has not indexed; a corrupted Launch Services database after a macOS migration or restore.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/f4264ef292fab140. Report an issue: GitHub.