Skip to content

Bug: macOS default browser detection falls back to Chrome when Edge (or other Chromium browsers) is set as system default #48560

@zoherghadyali

Description

@zoherghadyali

Summary

On macOS, detectDefaultChromiumExecutableMac() correctly reads the system default browser bundle ID from LaunchServices (e.g. com.microsoft.edgemac), but the subsequent osascript-based path resolution silently fails, causing a fallback to the hardcoded candidate list which starts with Chrome.

Repro

  1. Set Microsoft Edge as your macOS default browser (System Settings → Desktop & Dock → Default web browser)
  2. Start OpenClaw with no browser.executablePath override
  3. Run openclaw browser status

Expected: detectedBrowser: edge, detectedPath: /Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge
Actual: detectedBrowser: chrome, detectedPath: /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

Root Cause

In detectDefaultChromiumExecutableMac():

const appPathRaw = execText('/usr/bin/osascript', ['-e', `POSIX path of (path to application id "${bundleId}")`]);
if (!appPathRaw) return null;  // ← silently returns null

const exeName = execText('/usr/bin/defaults', ['read', path.join(appPath, 'Contents', 'Info'), 'CFBundleExecutable']);
if (!exeName) return null;  // ← or here

The osascript call uses com.microsoft.edgemac (the LaunchServices bundle ID), but this may not match the bundle ID registered in Edge's Info.plist (com.microsoft.Edge), causing the lookup to fail. When either call returns null, the function returns null and the code falls through to the hardcoded fallback list (Chrome first).

Suggested Fix

Add a fallback path resolution map for known bundle IDs before giving up:

const KNOWN_BUNDLE_ID_PATHS: Record<string, string> = {
  'com.microsoft.edgemac':       '/Applications/Microsoft Edge.app/Contents/MacOS/Microsoft Edge',
  'com.microsoft.edgemac.beta':  '/Applications/Microsoft Edge Beta.app/Contents/MacOS/Microsoft Edge Beta',
  'com.microsoft.edgemac.dev':   '/Applications/Microsoft Edge Dev.app/Contents/MacOS/Microsoft Edge Dev',
  'com.brave.browser':           '/Applications/Brave Browser.app/Contents/MacOS/Brave Browser',
  // etc.
};

If osascript/defaults resolution fails, try the known path from the map before returning null. Also add existence check (fs.existsSync) before returning.

Environment

  • macOS (Darwin 24.6.0, x64)
  • OpenClaw 2026.3.13
  • Default browser: Microsoft Edge (com.microsoft.edgemac)
  • Chrome also installed (causes incorrect fallback)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions