{"record":{"id":"7f5e28cab70ba500","repo":"zed-industries/zed","slug":"failed-to-register","errorCode":null,"errorMessage":"Failed to register: {}","messagePattern":"Failed to register: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_macos/src/platform.rs","lineNumber":790,"sourceCode":"        }\n\n        let Some(bundle_id) = NSBundle::mainBundle().bundleIdentifier() else {\n            return Task::ready(Err(anyhow!(\"Can only register URL scheme in bundled apps\")));\n        };\n\n        let workspace = NSWorkspace::sharedWorkspace();\n        let Some(app) = workspace.URLForApplicationWithBundleIdentifier(&bundle_id) else {\n            return Task::ready(Err(anyhow!(\n                \"Cannot register URL scheme until app is installed\"\n            )));\n        };\n\n        let scheme = NSString::from_str(scheme);\n\n        let done_tx = Cell::new(Some(done_tx));\n        let handler = RcBlock::new(move |error: *mut NSError| {\n            let result = if let Some(error) = unsafe { error.as_ref() } {\n                Err(anyhow!(\n                    \"Failed to register: {}\",\n                    error.localizedDescription()\n                ))\n            } else {\n                Ok(())\n            };\n\n            if let Some(done_tx) = done_tx.take() {\n                _ = done_tx.send(result);\n            }\n        });\n\n        workspace.setDefaultApplicationAtURL_toOpenURLsWithScheme_completionHandler(\n            &app,\n            &scheme,\n            Some(&handler),\n        );\n","sourceCodeStart":772,"sourceCodeEnd":808,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_macos/src/platform.rs#L772-L808","documentation":"In register_url_scheme on macOS, gpui calls LSSetDefaultHandlerForURLScheme (via the modern API) with a completion block; if macOS reports an NSError, the localized description is wrapped into this anyhow error. It means the OS refused to register the application as the handler for the URL scheme.","triggerScenarios":"Calling register_url_scheme and the async macOS registration callback receives a non-nil NSError, e.g. the scheme is invalid, the app bundle is not properly registered with LaunchServices, or the system denies the registration.","commonSituations":"Running the binary outside a proper .app bundle (bare executable launched from cargo), so LaunchServices cannot register it; running in a sandboxed/restricted environment; attempting to register a malformed scheme; macOS security policies blocking handler changes.","solutions":["Run the app as a properly bundled, signed .app so LaunchServices recognizes it (not a bare binary via `cargo run`).","Read the wrapped NSError description to see macOS's specific refusal reason.","Verify the CFBundleURLTypes entry for the scheme exists in the app's Info.plist.","Re-register the bundle with LaunchServices (e.g. lsregister) or reinstall the app.","Check the scheme string is valid and consistent with the Info.plist configuration."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Verify the app is bundled before attempting scheme registration\nlet is_bundled = std::env::current_exe()\n    .map(|p| p.ancestors().any(|a| a.extension().map_or(false, |e| e == \"app\")))\n    .unwrap_or(false);","typeGuard":null,"tryCatchPattern":"match platform.register_url_scheme(\"zed\") {\n    Err(e) if e.to_string().starts_with(\"Failed to register:\") => {\n        log::error!(\"URL scheme registration refused by macOS: {e}; run from a signed .app bundle\");\n    }\n    other => other?,\n}","preventionTips":["Always distribute/run the app as a signed .app bundle, not a bare binary.","Declare the scheme in CFBundleURLTypes in Info.plist before registering at runtime.","Re-grant/re-register with LaunchServices after re-signing or moving the bundle.","Read the embedded NSError description for macOS's specific refusal reason."],"tags":["macos","gpui","url-scheme","launchservices","registration"],"backgroundTag":"api-error-response","analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-09-12T19:35:53.743Z","contentChangedAt":"2026-09-12T19:35:53.743Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}