zed-industries/zed · error

Can only register URL scheme in bundled apps

Error message

Can only register URL scheme in bundled apps

What it means

Guard in register_url_scheme: NSBundle.mainBundle.bundleIdentifier returned nil, meaning the process is not running inside an .app bundle (e.g. launched via cargo run or a bare binary), so there is no bundle identity to register as the default handler.

Source

Thrown at crates/gpui_macos/src/platform.rs:775

            let workspace: id = msg_send![class!(NSWorkspace), sharedWorkspace];
            msg_send![workspace, openURL: url]
        }
    }

    fn register_url_scheme(&self, scheme: &str) -> Task<anyhow::Result<()>> {
        use objc2_foundation::{NSBundle, NSError, NSString};

        // API only available post Monterey
        // https://developer.apple.com/documentation/appkit/nsworkspace/3753004-setdefaultapplicationaturl
        let (done_tx, done_rx) = oneshot::channel();
        if Self::os_version() < Version::new(12, 0, 0) {
            return Task::ready(Err(anyhow!(
                "macOS 12.0 or later is required to register URL schemes"
            )));
        }

        let Some(bundle_id) = NSBundle::mainBundle().bundleIdentifier() else {
            return Task::ready(Err(anyhow!("Can only register URL scheme in bundled apps")));
        };

        let workspace = NSWorkspace::sharedWorkspace();
        let Some(app) = workspace.URLForApplicationWithBundleIdentifier(&bundle_id) else {
            return Task::ready(Err(anyhow!(
                "Cannot register URL scheme until app is installed"
            )));
        };

        let scheme = NSString::from_str(scheme);

        let done_tx = Cell::new(Some(done_tx));
        let handler = RcBlock::new(move |error: *mut NSError| {
            let result = if let Some(error) = unsafe { error.as_ref() } {
                Err(anyhow!(
                    "Failed to register: {}",
                    error.localizedDescription()
                ))

View on GitHub (pinned to 9d272b0363)

Solutions

  1. Package the app as a proper .app bundle with a CFBundleIdentifier before offering scheme registration
  2. In dev builds, skip or hide the URL-scheme registration feature
  3. Report the limitation to the caller so it can show guidance instead of silently failing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/gpui_macos/src/platform.rs:738 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12). Data as JSON: /api/errors/f31d3069742027eb. Report an issue: GitHub.