{"record":{"id":"caed17f3c50f1856","repo":"thedotmack/claude-mem","slug":"bun-install-failed-in-targetdir-describeexece","errorCode":null,"errorMessage":"bun install failed in ${targetDir}\n${describeExecError(err)}","messagePattern":"bun install failed in (.+?)\n(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/npx-cli/install/setup-runtime.ts","lineNumber":481,"sourceCode":"  // stall. execFile (not exec) passes bunPath as argv[0] with no shell, so a\n  // resolved path with spaces or shell metacharacters is never parsed.\n  const runBunInstall = (): Promise<void> =>\n    new Promise<void>((resolve, reject) => {\n      execFile(bunPath, ['install', '--frozen-lockfile', '--ignore-scripts'], {\n        cwd: targetDir,\n        timeout: INSTALL_TIMEOUT_MS,\n        maxBuffer: 16 * 1024 * 1024,\n        ...(IS_WINDOWS ? { windowsHide: true } : {}),\n      }, (error, stdout, stderr) =>\n        // execFile errors don't carry stdio; attach so describeExecError can report it.\n        error ? reject(Object.assign(error, { stdout, stderr })) : resolve());\n    });\n\n  try {\n    await runBunInstall();\n  } catch (error) {\n    const err = error instanceof Error ? error : new Error(String(error));\n    throw new Error(`bun install failed in ${targetDir}\\n${describeExecError(err)}`);\n  }\n\n  verifyCriticalModules(targetDir);\n}\n\nexport function readInstallMarker(targetDir: string): MarkerSchema | null {\n  const path = markerPath(targetDir);\n  if (!existsSync(path)) return null;\n  const content = readFileSync(path, 'utf-8');\n  try {\n    const marker = JSON.parse(content);\n    if (marker && typeof marker === 'object' && typeof marker.version === 'string') {\n      return marker as MarkerSchema;\n    }\n  } catch {\n    // Legacy installs wrote only the version string as plain text.\n  }\n","sourceCodeStart":463,"sourceCodeEnd":499,"githubUrl":"https://github.com/thedotmack/claude-mem/blob/d8bc9755e74915e5c3b999181e10a67c889bce2a/src/npx-cli/install/setup-runtime.ts#L463-L499","documentation":"installPluginDependencies runs 'bun install' in the plugin target directory and, if it fails, rethrows with the target directory and the underlying exec error from describeExecError. This identifies exactly which directory's dependency install failed and why.","triggerScenarios":"runBunInstall() throws during installPluginDependencies — bun missing from PATH, network failure fetching packages, lockfile mismatch, or script errors in the target dir.","commonSituations":"Bun not installed (ensureBun failed silently upstream), firewall blocking the npm registry, corrupted bun.lock, or insufficient write permissions in targetDir.","solutions":["Ensure bun is installed and on PATH ('which bun'); run the runtime setup if not.","Read the wrapped describeExecError output for the root cause and fix it (network, permissions, lockfile).","Delete node_modules/bun.lock in the target directory and re-run install/repair.","Re-run 'npx claude-mem install' or the repair command to retry."],"exampleFix":"// before\nnpx claude-mem install   # 'bun install failed in /home/x/.claude-mem/plugin'\n// after\ncd /home/x/.claude-mem/plugin\nrm -rf node_modules bun.lock\nbun install   # diagnose the real error, then re-run installer","handlingStrategy":"try-catch","validationCode":"import { execSync } from 'child_process';\nconst bunAvailable = (() => { try { execSync('bun --version', { stdio: 'ignore' }); return true; } catch { return false; } })();\nif (!bunAvailable) await ensureBun();","typeGuard":null,"tryCatchPattern":"try {\n  await installPluginDependencies(dir);\n} catch (e) {\n  if (/bun install failed in/.test(String(e))) {\n    console.error(e); // wrapped describeExecError shows registry/network cause\n    // retry after fixing bun PATH or network\n  }\n}","preventionTips":["Install bun and confirm it is on PATH before running the installer.","Ensure registry access (npm registry) isn't blocked by proxy/firewall.","Keep the plugin target directory writable by the current user.","Regenerate bun.lock instead of reusing one from another platform."],"tags":["bun","npm-install","dependencies"],"backgroundTag":"http-request-failed","analyzedSha":"d8bc9755e74915e5c3b999181e10a67c889bce2a","analyzedAt":"2026-09-17T16:40:26.182Z","contentChangedAt":"2026-09-17T16:40:26.182Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}