{"record":{"id":"55bba88a8b03f2c3","repo":"can1357/oh-my-pi","slug":"bun-pm-pack-failed","errorCode":null,"errorMessage":"bun pm pack failed","messagePattern":"bun pm pack failed","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/runner.ts","lineNumber":996,"sourceCode":"function readPkgVersion(): string {\n\tconst raw = readJson(path.join(CODING_AGENT_DIR, \"package.json\"));\n\tif (raw && typeof raw === \"object\") {\n\t\tconst v = (raw as Record<string, unknown>).version;\n\t\tif (typeof v === \"string\") return v;\n\t}\n\treturn \"latest\";\n}\n\nfunction buildTarball(benchDir: string): string {\n\tprocess.stdout.write(dim(\"packing local omp (bun pm pack)…\\n\"));\n\tconst r = spawnSync(\"bun\", [\"pm\", \"pack\", \"--destination\", benchDir], {\n\t\tcwd: CODING_AGENT_DIR,\n\t\tencoding: \"utf8\",\n\t\tstdio: [\"ignore\", \"pipe\", \"pipe\"],\n\t});\n\tif (r.status !== 0) {\n\t\tprocess.stderr.write((r.stdout ?? \"\") + (r.stderr ?? \"\"));\n\t\tthrow new Error(\"bun pm pack failed\");\n\t}\n\tconst tgz = fs\n\t\t.readdirSync(benchDir)\n\t\t.filter(f => f.endsWith(\".tgz\"))\n\t\t.map(f => ({ f, m: fs.statSync(path.join(benchDir, f)).mtimeMs }))\n\t\t.sort((a, b) => b.m - a.m)[0];\n\tif (!tgz) throw new Error(\"no .tgz produced by bun pm pack\");\n\treturn path.join(benchDir, tgz.f);\n}\n\nfunction newestTarball(benchDir: string): string | null {\n\ttry {\n\t\tconst tgz = fs\n\t\t\t.readdirSync(benchDir)\n\t\t\t.filter(f => f.endsWith(\".tgz\"))\n\t\t\t.map(f => ({ f, m: fs.statSync(path.join(benchDir, f)).mtimeMs }))\n\t\t\t.sort((a, b) => b.m - a.m)[0];\n\t\treturn tgz ? path.join(benchDir, tgz.f) : null;","sourceCodeStart":978,"sourceCodeEnd":1014,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/runner.ts#L978-L1014","documentation":"When building the coding-agent from source for the 'source' install mode, the runner shells out to `bun pm pack` in the coding-agent directory. If the command exits non-zero, the runner dumps its captured stdout/stderr to stderr and throws this generic wrapper error. The real cause is in the piped output, not the message itself.","triggerScenarios":"bun not installed or wrong version; the coding-agent package has a broken package.json; bun pm pack fails due to a registry/network issue resolving pack metadata; filesystem permission problems writing the tarball into benchDir.","commonSituations":"Fresh machine without bun in PATH for the harness process; dirty worktree with missing workspace deps (needs `bun install` first); disk full; running in CI where the monorepo was partially checked out.","solutions":["Re-run with the stderr shown just before the throw — it contains bun's actual error message; fix that root cause.","Ensure bun is installed and on PATH: `which bun && bun --version`.","Run `bun install` in packages/coding-agent (and repo root) so pack has a consistent lockfile/workspace.","Verify packages/coding-agent/package.json is valid and the package name/version fields are sane.","Check disk space and write permissions on the bench directory."],"exampleFix":"// before (shell, reproducing what the runner runs)\ncd packages/coding-agent && bun pm pack   # fails: no node_modules\n// after\nbun install && cd packages/coding-agent && bun pm pack","handlingStrategy":"try-catch","validationCode":"import { $ } from \"bun\";\nconst bunPath = await $`which bun`.quiet().nothrow();\nif (bunPath.exitCode !== 0) throw new Error(\"bun is required to pack the coding-agent from source\");","typeGuard":null,"tryCatchPattern":"try {\n  await buildFromSource();\n} catch (e) {\n  if (e instanceof Error && e.message === \"bun pm pack failed\") {\n    // root cause was already written to stderr by the runner\n    console.error(\"bun pm pack failed — check the stderr above (bun missing? deps not installed?).\");\n  } else throw e;\n}","preventionTips":["Install/verify bun before running source-mode harness jobs.","Run bun install at the repo root so workspaces are linked before packing.","Ensure adequate disk space and write access to the bench dir in CI."],"tags":["build","bun","pack","subprocess"],"backgroundTag":"package-build-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}