{"record":{"id":"424e69486ec7febd","repo":"can1357/oh-my-pi","slug":"bun-pm-cache-failed-cacheresult-stderr","errorCode":null,"errorMessage":"bun pm cache failed: ${cacheResult.stderr}","messagePattern":"bun pm cache failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/extensibility/plugins/bun-git-cache.ts","lineNumber":51,"sourceCode":"\t\tconst host = scpLike[1]?.toLowerCase() ?? \"\";\n\t\tconst repoPath = (scpLike[2] ?? \"\").replace(/^\\/+|\\/+$/g, \"\").replace(/\\.git$/i, \"\");\n\t\treturn `ssh://${host}/${repoPath}`;\n\t}\n\n\ttry {\n\t\tconst parsed = new URL(withoutFragment);\n\t\tconst repoPath = parsed.pathname.replace(/^\\/+|\\/+$/g, \"\").replace(/\\.git$/i, \"\");\n\t\treturn `${parsed.protocol.toLowerCase()}//${parsed.host.toLowerCase()}/${repoPath}`;\n\t} catch {\n\t\treturn withoutFragment.replace(/\\/+$/g, \"\").replace(/\\.git$/i, \"\");\n\t}\n}\n\n/** Fetches current heads and tags into Bun's matching cached bare clone before a plugin update. */\nexport async function refreshBunGitCache(source: GitSource, cwd: string): Promise<void> {\n\tconst cacheResult = await runCommand([\"bun\", \"pm\", \"cache\"], cwd);\n\tif (cacheResult.exitCode !== 0) {\n\t\tthrow new Error(`bun pm cache failed: ${cacheResult.stderr}`);\n\t}\n\tconst cacheDir = cacheResult.stdout.trim();\n\tif (!cacheDir) {\n\t\tthrow new Error(\"bun pm cache returned an empty cache path\");\n\t}\n\n\tlet entries: Dirent[];\n\ttry {\n\t\tentries = await fs.readdir(cacheDir, { withFileTypes: true });\n\t} catch (err) {\n\t\tif (isEnoent(err)) return;\n\t\tthrow err;\n\t}\n\n\tconst repositoryUrl = normalizeRepositoryUrl(source.repo);\n\tfor (const entry of entries) {\n\t\tif (!entry.isDirectory() || !entry.name.endsWith(\".git\")) continue;\n\t\tconst repositoryDir = path.join(cacheDir, entry.name);","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/extensibility/plugins/bun-git-cache.ts#L33-L69","documentation":"refreshBunGitCache runs `bun pm cache` in the given cwd before a plugin git update so Bun's cached bare clone is fresh. If the command exits non-zero it throws with the captured stderr. This is the pre-update cache bootstrap for git-hosted plugin installs.","triggerScenarios":"Installing/updating a git-sourced plugin when `bun pm cache` fails — bun not on PATH, broken bun installation, or the command erroring in the plugin's cwd.","commonSituations":"bun not installed or an old bun version lacking `pm cache`; restricted environment/CI where bun cannot write its cache dir; PATH differences between shell and the process spawning the installer.","solutions":["Run `bun pm cache` manually in the same directory to see the real error.","Ensure bun is installed and on PATH (`which bun`; check version — `bun pm cache` needs a recent bun).","Upgrade bun (`bun upgrade`) if the subcommand is missing.","Fix permissions/home dir issues that prevent bun from accessing its cache."],"exampleFix":"// verify before installing\n$ bun pm cache\n/Users/you/.bun/install/cache  # must succeed and print a path","handlingStrategy":"try-catch","validationCode":"const proc = Bun.spawn([\"bun\", \"pm\", \"cache\"], { stdout: \"pipe\", stderr: \"pipe\" });\nconst [code, out] = await Promise.all([proc.exited, new Response(proc.stdout).text()]);\nif (code !== 0 || !out.trim()) throw new Error(\"bun pm cache unavailable\");\n// only then call installPlugin/updatePlugin","typeGuard":"function isBunAvailable(): boolean {\n  const which = Bun.which(\"bun\");\n  return typeof which === \"string\" && which.length > 0;\n}","tryCatchPattern":"try {\n  await updateGitPlugin(source, cwd);\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith(\"bun pm cache failed:\")) {\n    logger.warn(\"Skipping bun cache refresh\", { stderr: err.message });\n    // proceed without refresh or abort install deliberately\n  } else throw err;\n}","preventionTips":["Pin/verify bun on PATH in CI and production images","Keep bun up to date (`bun upgrade`)","Smoke-test `bun pm cache` during environment setup"],"tags":["bun","git","plugins","process-execution","cache"],"backgroundTag":"bun-command-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}