zed-industries/zed · error
Failed to register
Error message
Failed to register: {} What it means
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.
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Verify the app is bundled before attempting scheme registration
let is_bundled = std::env::current_exe()
.map(|p| p.ancestors().any(|a| a.extension().map_or(false, |e| e == "app")))
.unwrap_or(false); Try / catch
match platform.register_url_scheme("zed") {
Err(e) if e.to_string().starts_with("Failed to register:") => {
log::error!("URL scheme registration refused by macOS: {e}; run from a signed .app bundle");
}
other => other?,
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not determine app path for
- Failed to get active display list. Result
- RealtimeAudio priority should use spawn_realtime, not…
- Screen share failed
- Screen share failed
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-09-12).
Data as JSON: /api/errors/7f5e28cab70ba500.
Report an issue: GitHub.
Appendix: source
Thrown at crates/gpui_macos/src/platform.rs:790
}
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()
))
} else {
Ok(())
};
if let Some(done_tx) = done_tx.take() {
_ = done_tx.send(result);
}
});
workspace.setDefaultApplicationAtURL_toOpenURLsWithScheme_completionHandler(
&app,
&scheme,
Some(&handler),
);
View on GitHub (pinned to 9d272b0363)