{"record":{"id":"8906aad46486a609","repo":"thedotmack/claude-mem","slug":"cannot-lazy-spawn-worker-bun-runtime-not-found-on","errorCode":null,"errorMessage":"Cannot lazy-spawn worker: Bun runtime not found on PATH","messagePattern":"Cannot lazy-spawn worker: Bun runtime not found on PATH","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/shared/worker-utils.ts","lineNumber":553,"sourceCode":"      return false;\n    }\n    if (!(await waitForWorkerPortClosed())) {\n      logger.error('SYSTEM', 'Stale worker port still open after SIGKILL; skipping spawn this hook event', {\n        pid: stalePidInfo.pid,\n        port: getWorkerPort(),\n      });\n      return false;\n    }\n    // The killed worker's PID file is left behind; the successor's boot\n    // removes it (validateWorkerPidFile returns 'stale' for a dead pid).\n    // Fall through to (re)spawn + readiness wait below.\n  }\n\n  const runtimePath = resolveWorkerRuntimePath();\n  const scriptPath = resolvedScript?.scriptPath ?? null;\n\n  if (!runtimePath) {\n    logger.warn('SYSTEM', 'Cannot lazy-spawn worker: Bun runtime not found on PATH');\n    return false;\n  }\n  if (!scriptPath) {\n    logger.warn('SYSTEM', 'Cannot lazy-spawn worker: worker-service.cjs not found in plugin/scripts');\n    return false;\n  }\n\n  // Spawn gate (worker-spawn-gate.ts): only ONE gated launcher — hook, MCP\n  // server, or the CLI restart fallback — may spawn at a time. (The dying\n  // worker's restart handoff in worker-shutdown.ts is deliberately NOT gated:\n  // it is the spawner for CLI-initiated restarts. Hook version recycles never\n  // trigger it — they SIGKILL the stale worker and spawn here.)\n  // Losing the lock never fails the hook; the loser skips its spawn and waits\n  // for the winner's worker on the existing port/readiness waits below. The\n  // winner holds the lock through the port-open wait (the spawn isn't \"done\"\n  // until the worker owns the port) and releases in finally on every exit\n  // path.\n  const spawnLockHeld = acquireSpawnLock();","sourceCodeStart":535,"sourceCodeEnd":571,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/8bc631a71a487424b866756e43a6efa4574cc66b/src/shared/worker-utils.ts#L535-L571","documentation":"Lazy-spawn needs the Bun runtime to start the worker; resolveWorkerRuntimePath() returned null (no bun executable found on the PATH of the Claude Code process running hooks). The hook warns, returns false, and the whole hook event runs without worker-backed features (no memory injection).","triggerScenarios":"Bun was never installed, was uninstalled, or exists only for a different user/shell so the Claude Code process's PATH does not include ~/.bun/bin. resolveWorkerRuntimePath() returns null and the spawn path aborts before resolving a script.","commonSituations":"Fresh machine; Bun installed via a shell config not sourced by GUI-launched Claude Desktop; PATH customized per-terminal so hooks see a different environment.","solutions":["Install Bun (curl -fsSL https://bun.sh/install | bash) and fully restart the terminal/Claude so PATH updates propagate.","Verify with `bun --version` run from the same environment that launches Claude Code.","For GUI launches, make sure ~/.bun/bin is on the global PATH (launchctl setenv PATH, /etc/paths, or equivalent).","Re-run npm run build-and-sync in the claude-mem checkout — its setup auto-installs Bun when missing."],"exampleFix":"# before: bun only in an interactive shell profile\n# (GUI-launched Claude Code never sources it)\n\n# after: ensure global visibility\nlaunchctl setenv PATH \"$HOME/.bun/bin:$PATH\"  # macOS GUI apps\n# then restart Claude Desktop","handlingStrategy":"validation","validationCode":"const runtimePath = resolveWorkerRuntimePath();\nif (!runtimePath) {\n  // install Bun or fix PATH before hooks need the worker\n  failEarlyWithHint('Install Bun: curl -fsSL https://bun.sh/install | bash');\n}","typeGuard":"const hasBunOnPath = (): boolean => resolveWorkerRuntimePath() !== null;","tryCatchPattern":null,"preventionTips":["Install Bun up front and verify `bun --version` from the process that launches Claude Code.","For GUI-launched apps, put ~/.bun/bin on the global PATH (launchctl setenv / /etc/paths).","Re-run npm run build-and-sync after system setup — it auto-installs missing runtimes."],"tags":["bun","runtime-not-found","path","worker-spawn","claude-mem"],"backgroundTag":"runtime-not-found","analyzedSha":"8bc631a71a487424b866756e43a6efa4574cc66b","analyzedAt":"2026-08-20T23:58:13.836Z","contentChangedAt":"2026-08-20T23:58:13.836Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}