{"record":{"id":"e754fe968fc57228","repo":"different-ai/openwork","slug":"xdg-mime-could-not-register-openwork","errorCode":null,"errorMessage":"xdg-mime could not register openwork://.","messagePattern":"xdg-mime could not register openwork://\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"apps/desktop/electron/linux-desktop-integration.mjs","lineNumber":447,"sourceCode":"      }\n      await atomicWrite(desktopEntryPath, buildOpenworkDesktopEntry({\n        appImagePath,\n        appName,\n        appVersion: app.getVersion(),\n        distribution,\n      }));\n\n      const state = await readState();\n      if (before.handlerDesktopId && before.handlerDesktopId !== OPENWORK_DESKTOP_ID) {\n        state.previousProtocolHandler = before.handlerDesktopId;\n      }\n      state.dismissedAppImages = state.dismissedAppImages.filter((candidate) => candidate !== appImagePath);\n      await writeState(state);\n\n      await refreshDesktopCaches();\n      const registration = await runCommand(\"xdg-mime\", [\"default\", OPENWORK_DESKTOP_ID, OPENWORK_PROTOCOL_MIME]);\n      if (!registration.ok) {\n        throw new Error(registration.stderr || \"xdg-mime could not register openwork://.\");\n      }\n      const status = await getStatus();\n      if (status.state !== \"integrated\") {\n        throw new Error(\"The desktop entry was installed, but the desktop did not select it as the openwork:// handler.\");\n      }\n      return { ok: true, status };\n    } catch (error) {\n      return {\n        ok: false,\n        status: await getStatus(),\n        error: error instanceof Error ? error.message : String(error),\n      };\n    }\n  }\n\n  /** @returns {Promise<DesktopIntegrationResult>} */\n  async function remove() {\n    if (!supported) {","sourceCodeStart":429,"sourceCodeEnd":465,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/linux-desktop-integration.mjs#L429-L465","documentation":"During Linux AppImage desktop integration, install() writes the .desktop entry and icons, then registers OpenWork as the openwork:// x-scheme-handler by running `xdg-mime default <desktop-id> <mime>`. If that command exits non-zero (registration.ok false), it throws either the command's stderr or this fallback message.","triggerScenarios":"install() on Linux when `xdg-mime` is missing from PATH, exits non-zero, or writes nothing to stderr so the fallback message is used; also when the XDG data dirs are not writable so the mimeapps.list update fails.","commonSituations":"Minimal/headless or Wayland-only environments without xdg-utils installed; containerized or snap/flatpak-sandboxed apps where xdg-mime cannot write to ~/.config/mimeapps.list; corrupt PATH in the spawned environment.","solutions":["Install xdg-utils (`sudo apt install xdg-utils` / `dnf install xdg-utils`) so xdg-mime is on PATH.","Run the app outside sandbox confinement or grant write access to ~/.config/mimeapps.list.","Manually set the handler (`xdg-mime default openwork.desktop x-scheme-handler/openwork`) and re-run integration to confirm.","If the message appears instead of stderr, capture the exit code of the registration command to find the real failure."],"exampleFix":"// before\nawait install(); // throws when xdg-mime absent\n// after\nif (!commandExists('xdg-mime')) {\n  console.error('Install xdg-utils to enable openwork:// registration.');\n  return;\n}\nawait install();","handlingStrategy":"try-catch","validationCode":"import { execFileSync } from 'node:child_process';\nfunction xdgMimeAvailable() {\n  try { execFileSync('xdg-mime', ['--version'], { stdio: 'ignore' }); return true; }\n  catch { return false; }\n}","typeGuard":null,"tryCatchPattern":"try {\n  const res = await integration.install();\n  if (!res.ok) console.error('openwork:// registration failed:', res.error);\n} catch (err) {\n  console.error('xdg-mime registration failed:', err.message);\n}","preventionTips":["Install xdg-utils on target Linux images and CI containers.","Verify ~/.config/mimeapps.list is writable before integrating.","Test integration outside snap/flatpak confinement where xdg-mime writes are blocked.","Check `xdg-mime --version` availability at app startup and degrade gracefully."],"tags":["linux","xdg","desktop-integration"],"backgroundTag":"xdg-mime-registration-failed","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}