zed-industries/zed · error

macOS 12.0 or later is required to register URL schemes

Error message

macOS 12.0 or later is required to register URL schemes

What it means

Guard in register_url_scheme: the macOS version check (Version::new(12,0,0)) failed because NSWorkspace.setDefaultApplicationAtURL(toURL:contentType:) is only available from macOS 12 (Monterey). The API is invoked unconditionally otherwise, so the guard rejects older systems up front.

Source

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

    fn open_url(&self, url: &str) {
        unsafe {
            let ns_url = NSURL::alloc(nil).initWithString_(ns_string(url));
            if ns_url.is_null() {
                log::error!("Failed to create NSURL from string: {}", url);
                return;
            }
            let url = ns_url.autorelease();
            let workspace: id = msg_send![class!(NSWorkspace), sharedWorkspace];
            msg_send![workspace, openURL: url]
        }
    }

    fn register_url_scheme(&self, scheme: &str) -> Task<anyhow::Result<()>> {
        // 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 bundle_id = unsafe {
            let bundle: id = msg_send![class!(NSBundle), mainBundle];
            let bundle_id: id = msg_send![bundle, bundleIdentifier];
            if bundle_id == nil {
                return Task::ready(Err(anyhow!("Can only register URL scheme in bundled apps")));
            }
            bundle_id
        };

        unsafe {
            let workspace: id = msg_send![class!(NSWorkspace), sharedWorkspace];
            let scheme: id = ns_string(scheme);
            let app: id = msg_send![workspace, URLForApplicationWithBundleIdentifier: bundle_id];
            if app == nil {

View on GitHub (pinned to f4178619ac)

Solutions

  1. Gate the register-url-scheme feature behind a macOS 12 availability check in the UI
  2. On older macOS, fall back to directing users to change the default handler manually
  3. Use ProcessInfo.operatingSystemVersion (as here) rather than weak-linked symbols to decide availability
Defensive patterns

Strategy: validation

When it happens

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

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/4c36816cf99fc7be. Report an issue: GitHub.