{"record":{"id":"b47c98bb025b5cda","repo":"can1357/oh-my-pi","slug":"no-tgz-produced-by-bun-pm-pack","errorCode":null,"errorMessage":"no .tgz produced by bun pm pack","messagePattern":"no \\.tgz produced by bun pm pack","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/runner.ts","lineNumber":1003,"sourceCode":"}\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;\n\t} catch {\n\t\treturn null;\n\t}\n}\n\n// ─────────────────────────────────────────────────────── source mount (--install source)\n","sourceCodeStart":985,"sourceCodeEnd":1021,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/runner.ts#L985-L1021","documentation":"After `bun pm pack` reports success, the runner scans benchDir for the newest *.tgz it should have produced. If none is found, it throws — meaning pack exited 0 but wrote the tarball somewhere else (or none at all), so the runner cannot proceed to install it.","triggerScenarios":"bun pm pack wrote the .tgz to the package directory rather than benchDir (bun versions/config differences); a leftover `.tgz` filtering mismatch (e.g. output named .tar.gz); bun's exit code 0 despite a no-op due to pack config (packageManager/publishConfig.packDestination) pointing elsewhere.","commonSituations":"Mixed bun versions between machines/CI where `bun pm pack` destination behavior differs; a publishConfig in package.json redirecting pack output; the tgz got created and immediately consumed/moved by a concurrent run sharing the same benchDir.","solutions":["Check where the tgz landed: `find . -name '*.tgz' -newer /tmp -mmin -5` and confirm pack's destination matches benchDir.","Run `bun pm pack` manually in packages/coding-agent to see the printed output path.","Remove publishConfig.packDestination or similar redirects from package.json so output lands in benchDir.","Align bun version with the one the harness expects (`bun --version` vs repo's packageManager/bun requirement).","Avoid concurrent runs sharing one benchDir; use a separate jobs dir per run."],"exampleFix":"// before\n\"publishConfig\": { \"packDestination\": \"../dist\" }   // pack output escapes benchDir\n// after\n// remove packDestination so the runner finds the .tgz in benchDir","handlingStrategy":"try-catch","validationCode":"import * as fs from \"node:fs\";\nconst before = fs.readdirSync(benchDir).filter(f => f.endsWith(\".tgz\"));\n// after invoking pack, verify exactly:\nconst after = fs.readdirSync(benchDir).filter(f => f.endsWith(\".tgz\"));\nif (after.length <= before.length) throw new Error(\"pack produced no new .tgz in benchDir\");","typeGuard":null,"tryCatchPattern":"try {\n  const tgz = packCodingAgent(benchDir);\n} catch (e) {\n  if (e instanceof Error && e.message === \"no .tgz produced by bun pm pack\") {\n    console.error(\"bun pm pack exited 0 but no .tgz landed in the bench dir — check pack destination config and bun version.\");\n  } else throw e;\n}","preventionTips":["Pin the bun version across machines/CI so pack output behavior is consistent.","Remove packDestination redirects from package.json publishConfig.","Don't share one benchDir across concurrent harness runs."],"tags":["build","bun","pack","artifact-not-found"],"backgroundTag":"package-build-failed","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}