thedotmack/claude-mem · critical · Error
plugin/scripts/bun-runner.js is missing fixBrokenScriptPath
Error message
plugin/scripts/bun-runner.js is missing fixBrokenScriptPath — it is the Rule C runtime safety net behind Rule A. Do not remove it.
What it means
A defensive guard ensuring plugin/scripts/bun-runner.js still defines function fixBrokenScriptPath. This function is the Rule C runtime safety net that repairs script paths when a host invokes the launcher with a stale or mismatched PLUGIN_ROOT. The build reads bun-runner.js and string-matches the function name; if absent it refuses to complete the build because removing the safety net would resurrect the script-path bugs Rule A/C were designed to prevent.
Source
Thrown at scripts/build-hooks.js:227
`Regenerate via \`node scripts/build-hooks.js --write-shell-templates\` after an intentional generator change.`
);
}
entry.commandWindows = expected.commandWindows;
dirty = true;
}
}
}
}
if (dirty) {
fs.writeFileSync(filePath, JSON.stringify(parsed, null, 2) + '\n');
console.log(` ✏️ Regenerated shell templates in ${filePath}`);
}
}
// Rule C safety net (bun-runner.js fixBrokenScriptPath) must stay documented.
const bunRunner = fs.readFileSync('plugin/scripts/bun-runner.js', 'utf-8');
if (!bunRunner.includes('function fixBrokenScriptPath')) {
throw new Error(
'plugin/scripts/bun-runner.js is missing fixBrokenScriptPath — it is the Rule C runtime safety net behind Rule A. Do not remove it.'
);
}
// Parser-compat guard (issue #2791): bun-runner.js is invoked by hosts that
// may run a pre-ES2020 Node whose ESM loader throws on optional chaining.
// Strip comments, then forbid `?.` / `??` in executable code.
const bunRunnerCode = bunRunner
.replace(/\/\*[\s\S]*?\*\//g, '')
.replace(/(^|[^:])\/\/.*$/gm, '$1');
if (/\?\.|\?\?/.test(bunRunnerCode)) {
throw new Error(
'plugin/scripts/bun-runner.js uses optional chaining (?.) or nullish coalescing (??) — ' +
'this launcher must parse on pre-ES2020 Node (issue #2791). Rewrite with explicit guards.'
);
}
console.log('✓ Rule A shell templates match the canonical generator');View on GitHub (pinned to d768ba3643)
Solutions
- Restore function fixBrokenScriptPath in plugin/scripts/bun-runner.js (git checkout HEAD -- plugin/scripts/bun-runner.js if the deletion was unintentional).
- If you intentionally relocated the logic, keep a thin `function fixBrokenScriptPath(...)` wrapper in bun-runner.js that calls the new location — the guard requires the symbol to live in this exact file.
- Re-run node scripts/build-hooks.js; the guard passes once the string 'function fixBrokenScriptPath' is present.
- Do not work around by editing the guard — Rule C exists because hosts ship stale PLUGIN_ROOT values and silently break; removing the net regresses that.
Example fix
// before: fixBrokenScriptPath removed from plugin/scripts/bun-runner.js
// restore it (canonical implementation lives in git history):
function fixBrokenScriptPath(scriptPath) {
// Rule C: repair stale PLUGIN_ROOT-derived paths at runtime
// ... existing body ...
}
// then: node scripts/build-hooks.js succeeds Defensive patterns
Strategy: validation
Validate before calling
// Quick local check mirroring the guard:
const src = fs.readFileSync('plugin/scripts/bun-runner.js', 'utf8');
if (!src.includes('function fixBrokenScriptPath')) {
throw new Error('Rule C safety net missing — restore fixBrokenScriptPath');
} Try / catch
// Build-time only, intentional fail-fast. Do not catch. Restore the function // (git checkout HEAD -- plugin/scripts/bun-runner.js) or keep a wrapper that // delegates to the new location.
Prevention
- Treat fixBrokenScriptPath as load-bearing — it's referenced as Rule C in the build.
- When refactoring bun-runner.js, leave the symbol in place even if it delegates elsewhere.
- Add a unit test that exercises fixBrokenScriptPath so deletions surface in tests, not just build.
When it happens
Trigger: Running the build after someone deleted or renamed fixBrokenScriptPath in plugin/scripts/bun-runner.js. Refactoring that moved the function into another file (so the string match fails even though the logic exists elsewhere). A bad merge that dropped the function.
Common situations: Aggressive refactor of bun-runner.js that 'inlines' or relocates path-fixing logic. Copy-paste of a minimal launcher that omits the safety net. Merge conflict resolution that drops the function.
Related errors
- Hand-edited shell string detected in ${filePath} (mcp-search
- Hand-edited shell string detected in ${filePath} (${dottedPa
- Hand-edited Windows shell string detected in ${filePath} (${
- plugin/scripts/bun-runner.js uses optional chaining (?.) or
- mcp-server.cjs contains a Bun-only ${bunRequireMatch[0]} cal
AI-assisted analysis of thedotmack/claude-mem@d768ba3643 (2026-08-12).
Data as JSON: /api/errors/f41e1959b4a008b0.
Report an issue: GitHub.