{"record":{"id":"1fbe72deeb288d02","repo":"garrytan/gstack","slug":"diagram-render-bundle-not-found-tried-candidat","errorCode":null,"errorMessage":"diagram-render bundle not found. Tried:\n${candidates.map((c) => `  - ${c}`).join(\"\\n\")}\nRun `bun run build:diagram-render` (repo) or re-run ./setup (install).","messagePattern":"diagram-render bundle not found\\. Tried:\n(.+?)`\\)\\.join\\(\"\\\\n\"\\)\\}\nRun `bun run build:diagram-render` \\(repo\\) or re-run \\./setup \\(install\\)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"make-pdf/src/diagram-prepass.ts","lineNumber":450,"sourceCode":"}\n\n/** Resolve dist/diagram-render.html: env override → repo-relative (dev) → global install. */\nexport function resolveBundlePath(env: NodeJS.ProcessEnv = process.env): string {\n  const candidates = [\n    env.GSTACK_DIAGRAM_BUNDLE,\n    // dev: make-pdf/src/* → repo root lib/. (In a compiled binary this is the\n    // virtual /$bunfs/root and simply never exists — harmless.)\n    path.resolve(import.meta.dir, \"../../lib/diagram-render/dist/diagram-render.html\"),\n    // compiled binary at <root>/make-pdf/dist/pdf → <root>/lib/… — same shape\n    // in the repo and in the ~/.claude/skills/gstack global install. argv[0]\n    // is the literal string \"bun\" in compiled binaries; execPath is real.\n    path.resolve(path.dirname(process.execPath), \"../../lib/diagram-render/dist/diagram-render.html\"),\n    path.join(os.homedir(), \".claude/skills/gstack/lib/diagram-render/dist/diagram-render.html\"),\n  ].filter((p): p is string => !!p);\n  for (const p of candidates) {\n    if (fs.existsSync(p)) return p;\n  }\n  throw new Error(\n    \"diagram-render bundle not found. Tried:\\n\" +\n    candidates.map((c) => `  - ${c}`).join(\"\\n\") +\n    \"\\nRun `bun run build:diagram-render` (repo) or re-run ./setup (install).\",\n  );\n}\n\n// ─── Fence rendering ──────────────────────────────────────────────────\n\n/**\n * Render every extracted fence to its slot HTML. One bundle tab serves all\n * fences; a failed fence yields a diagnostic block and a bundle reload\n * (reset contract) before the next fence renders.\n */\nexport function renderFenceSlots(\n  fences: DiagramFence[],\n  tab: RenderTab,\n  warn: (msg: string) => void,\n): Map<string, string> {","sourceCodeStart":432,"sourceCodeEnd":468,"githubUrl":"https://github.com/garrytan/gstack/blob/94993f74012782fd94416dd44b8314f6363a13a4/make-pdf/src/diagram-prepass.ts#L432-L468","documentation":"Thrown by resolveBundlePath() when none of the candidate paths for diagram-render.html exist: GSTACK_DIAGRAM_BUNDLE env, repo-relative lib/diagram-render/dist/diagram-render.html (dev), execPath-relative lib path (compiled binary), or the global ~/.claude/skills/gstack install. Without the bundle, the diagram pre-pass cannot render any fence.","triggerScenarios":"First run after `bun install` without `bun run build:diagram-render`; a compiled pdf binary whose layout differs from the expected dist/ shape; GSTACK_DIAGRAM_BUNDLE pointing to a moved/deleted file; a partial global install missing the lib/diagram-render tree.","commonSituations":"CI that runs make-pdf without the build step; a developer who cloned only make-pdf without the gstack super-repo; a packaged binary whose bundling omitted lib/; the bundle was gitignored and not present in a shallow clone.","solutions":["Run `bun run build:diagram-render` from the repo root to generate the bundle.","Re-run `./setup` from ~/.claude/skills/gstack to install the bundle globally.","Set GSTACK_DIAGRAM_BUNDLE to an absolute path of an existing diagram-render.html.","If packaging a binary, ensure lib/diagram-render/dist/diagram-render.html is included."],"exampleFix":"# before\n$ pdf report.md\nError: diagram-render bundle not found. Tried: ...\n\n# after — build then render\n$ bun run build:diagram-render\n$ export GSTACK_DIAGRAM_BUNDLE=\"$PWD/lib/diagram-render/dist/diagram-render.html\"\n$ pdf report.md","handlingStrategy":"validation","validationCode":"import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction ensureBundlePresent(env = process.env): string | null {\n  const candidates = [\n    env.GSTACK_DIAGRAM_BUNDLE,\n    path.resolve(process.cwd(), 'lib/diagram-render/dist/diagram-render.html'),\n    path.join(os.homedir(), '.claude/skills/gstack/lib/diagram-render/dist/diagram-render.html'),\n  ].filter((p): p is string => !!p);\n  return candidates.find(p => fs.existsSync(p)) ?? null;\n}\n\nconst bundle = ensureBundlePresent();\nif (!bundle) throw new Error('Run `bun run build:diagram-render` before rendering.');","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `bun run build:diagram-render` as part of your build script.","Bundle the lib/diagram-render tree when packaging a binary.","Set GSTACK_DIAGRAM_BUNDLE to an absolute path in CI.","Re-run ./setup after pulling releases that change the bundle."],"tags":["make-pdf","diagram","bundle","binary-resolution","build"],"backgroundTag":null,"analyzedSha":"94993f74012782fd94416dd44b8314f6363a13a4","analyzedAt":"2026-08-12T04:06:23.140Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}