garrytan/gstack · error · Error

diagram-render bundle not found. Tried: ${candidates.map((c)

Error message

diagram-render bundle not found. Tried:
${candidates.map((c) => `  - ${c}`).join("\n")}
Run `bun run build:diagram-render` (repo) or re-run ./setup (install).

What it means

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.

Source

Thrown at make-pdf/src/diagram-prepass.ts:450

}

/** Resolve dist/diagram-render.html: env override → repo-relative (dev) → global install. */
export function resolveBundlePath(env: NodeJS.ProcessEnv = process.env): string {
  const candidates = [
    env.GSTACK_DIAGRAM_BUNDLE,
    // dev: make-pdf/src/* → repo root lib/. (In a compiled binary this is the
    // virtual /$bunfs/root and simply never exists — harmless.)
    path.resolve(import.meta.dir, "../../lib/diagram-render/dist/diagram-render.html"),
    // compiled binary at <root>/make-pdf/dist/pdf → <root>/lib/… — same shape
    // in the repo and in the ~/.claude/skills/gstack global install. argv[0]
    // is the literal string "bun" in compiled binaries; execPath is real.
    path.resolve(path.dirname(process.execPath), "../../lib/diagram-render/dist/diagram-render.html"),
    path.join(os.homedir(), ".claude/skills/gstack/lib/diagram-render/dist/diagram-render.html"),
  ].filter((p): p is string => !!p);
  for (const p of candidates) {
    if (fs.existsSync(p)) return p;
  }
  throw new Error(
    "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).",
  );
}

// ─── Fence rendering ──────────────────────────────────────────────────

/**
 * Render every extracted fence to its slot HTML. One bundle tab serves all
 * fences; a failed fence yields a diagnostic block and a bundle reload
 * (reset contract) before the next fence renders.
 */
export function renderFenceSlots(
  fences: DiagramFence[],
  tab: RenderTab,
  warn: (msg: string) => void,
): Map<string, string> {

View on GitHub (pinned to 94993f7401)

Solutions

  1. Run `bun run build:diagram-render` from the repo root to generate the bundle.
  2. Re-run `./setup` from ~/.claude/skills/gstack to install the bundle globally.
  3. Set GSTACK_DIAGRAM_BUNDLE to an absolute path of an existing diagram-render.html.
  4. If packaging a binary, ensure lib/diagram-render/dist/diagram-render.html is included.

Example fix

# before
$ pdf report.md
Error: diagram-render bundle not found. Tried: ...

# after — build then render
$ bun run build:diagram-render
$ export GSTACK_DIAGRAM_BUNDLE="$PWD/lib/diagram-render/dist/diagram-render.html"
$ pdf report.md
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'node:fs';
import path from 'node:path';

function ensureBundlePresent(env = process.env): string | null {
  const candidates = [
    env.GSTACK_DIAGRAM_BUNDLE,
    path.resolve(process.cwd(), 'lib/diagram-render/dist/diagram-render.html'),
    path.join(os.homedir(), '.claude/skills/gstack/lib/diagram-render/dist/diagram-render.html'),
  ].filter((p): p is string => !!p);
  return candidates.find(p => fs.existsSync(p)) ?? null;
}

const bundle = ensureBundlePresent();
if (!bundle) throw new Error('Run `bun run build:diagram-render` before rendering.');

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of garrytan/gstack@94993f7401 (2026-08-12). Data as JSON: /api/errors/1fbe72deeb288d02. Report an issue: GitHub.