{"record":{"id":"b95542c4584c072e","repo":"different-ai/openwork","slug":"cannot-find-openwork-embedded-server-bundle-check","errorCode":null,"errorMessage":"Cannot find OpenWork embedded server bundle. Checked: ${candidates.join(\", \")}","messagePattern":"Cannot find OpenWork embedded server bundle\\. Checked: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"apps/desktop/electron/runtime.mjs","lineNumber":1938,"sourceCode":"    );\n    const activeWorkspace = selectStickyOpenworkPortWorkspace(requestedWorkspacePaths, workspacePaths);\n    const portSelection = await resolveOpenworkPort(host, activeWorkspace, currentPort);\n    const tokens = await loadServerCredentials();\n\n    // One call: resolve config, spawn managed OpenCode, start HTTP server.\n    // Dev must prefer apps/server/dist; build output also stages a packaged\n    // copy under apps/desktop/server for electron-builder.\n    const devPath = path.resolve(__runtimeDir, \"..\", \"..\", \"server\", \"dist\", \"embedded.js\");\n    const packagedPaths = [\n      path.resolve(__runtimeDir, \"..\", \"server\", \"dist\", \"embedded.js\"),\n      ...(process.resourcesPath ? [path.resolve(process.resourcesPath, \"server\", \"dist\", \"embedded.js\")] : []),\n    ];\n    const candidates = process.env.OPENWORK_DEV_MODE === \"1\"\n      ? [devPath, ...packagedPaths]\n      : [...packagedPaths, devPath];\n    const embeddedPath = candidates.find((candidate) => existsSync(candidate));\n    if (!embeddedPath) {\n      throw new Error(`Cannot find OpenWork embedded server bundle. Checked: ${candidates.join(\", \")}`);\n    }\n    const { startEmbeddedServer } = await import(embeddedServerImportUrl(embeddedPath));\n    // startEmbeddedServer falls back to an OS-assigned port if `port` races\n    // into EADDRINUSE (see apps/server/src/serve-node.ts), so the bound port\n    // below is authoritative.\n    const handle = await startEmbeddedServer({\n      host,\n      port: portSelection.port,\n      corsOrigins: [\"*\"],\n      approvalMode: \"auto\",\n      configPath: serverConfigPath,\n      workspaces: workspacePaths,\n      token: tokens.clientToken,\n      hostToken: tokens.hostToken,\n      opencodeBaseUrl: options.opencodeBaseUrl ?? undefined,\n      opencodeDirectory: activeWorkspace || undefined,\n      manageOpencode: options.manageOpencode === true,\n      opencodeBin: managedOpencode?.path ?? undefined,","sourceCodeStart":1920,"sourceCodeEnd":1956,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/apps/desktop/electron/runtime.mjs#L1920-L1956","documentation":"When starting the embedded OpenWork server, the runtime probes a list of candidate bundle paths (packaged paths plus a dev path, ordered by OPENWORK_DEV_MODE). If none of them exists on disk it throws this error listing every path it checked. It means the server bundle was never built or is installed somewhere the app doesn't expect.","triggerScenarios":"Starting the app (embedded server boot) when `existsSync` fails for every candidate: packaged bundle absent from install resources, or dev bundle absent and OPENWORK_DEV_MODE toggled incorrectly.","commonSituations":"Running from source without building the server (`@openwork/server` dist missing); a packaging/CI step that skipped bundling the server; setting OPENWORK_DEV_MODE=1 in an environment where the dev bundle was never built; installing an app build that shipped without the embedded server.","solutions":["Build the server bundle (`pnpm build` in apps/server or the repo's build-all script) so the dev path exists.","If running a packaged install, rebuild/repackage the desktop app so the server bundle is included in resources.","Set OPENWORK_DEV_MODE=1 only when the dev bundle exists; unset it to fall back to packaged paths (or vice versa).","Read the `Checked:` list in the error and confirm the expected path exists, then fix the packaging config or copy the bundle there."],"exampleFix":"// before\nexport OPENWORK_DEV_MODE=1   # dev bundle never built\n// after\npnpm --filter @openwork/server build && export OPENWORK_DEV_MODE=1","handlingStrategy":"fallback","validationCode":"const candidatePaths = process.env.OPENWORK_DEV_MODE === \"1\" ? [devPath, ...packagedPaths] : [...packagedPaths, devPath];\nif (!candidatePaths.some((p) => existsSync(p))) {\n  throw new Error(`Server bundle missing; build it or check packaging. Expected one of: ${candidatePaths.join(\", \")}`);\n}","typeGuard":null,"tryCatchPattern":"let handle;\ntry {\n  handle = await startOpenworkEmbeddedServer();\n} catch (err) {\n  if (String(err.message).startsWith(\"Cannot find OpenWork embedded server bundle\")) {\n    dialog.showErrorBox(\"Server bundle missing\", \"Rebuild the app: pnpm build && pnpm package\");\n    app.quit();\n  } else { throw err; }\n}","preventionTips":["Build the server bundle as a prerequisite step in dev scripts (predev hook).","Assert bundle presence in CI packaging output before publishing builds.","Keep OPENWORK_DEV_MODE set only in dev environments; use .env files per environment.","Log candidate paths at startup (debug level) so missing-bundle issues are diagnosable."],"tags":["build","packaging","electron"],"backgroundTag":"missing-build-artifact","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}