oven-sh/bun · error · Error
Could not find ## Contributing in README
Error message
Could not find ## Contributing in README
What it means
nav2readme.ts searches for `## Contributing\n` starting after the Quick links heading, to find where the injected guides block must end. If the heading is absent (or only appears before Quick links), indexOf returns -1 and the script aborts before rewriting the README.
Source
Thrown at scripts/nav2readme.ts:89
}
md +=
` - [${name}](https://bun.com/guides/${path.dirname(file)}/${path.basename(file, path.extname(file))})` + "\n";
}
return md;
}
const text = await Bun.file(Bun.fileURLToPath(import.meta.resolve("../README.md"))).text();
const startI = text.indexOf("## Quick links\n");
if (startI === -1) {
throw new Error("Could not find ## Quick links in README");
}
const start = startI + "## Quick links\n".length;
const contributing = text.indexOf("## Contributing\n", start);
if (contributing === -1) {
throw new Error("Could not find ## Contributing in README");
}
const guides = await getGuides();
const combined =
[text.slice(0, start), getQuickLinks(), guides, text.slice(contributing)].map(text => text.trim()).join("\n\n") +
"\n";
await Bun.write(Bun.fileURLToPath(import.meta.resolve("../README.md")), combined);
function normalizeSectionName(name: string) {
if (name.includes("-")) {
return name
.split("-")
.map((s, i) => (i === 0 ? s.charAt(0).toUpperCase() + s.slice(1) : s))
.join(" ");
}
View on GitHub (pinned to 8c5296ac45)
Solutions
- Ensure `## Contributing` exists in README.md below the `## Quick links` section, spelled exactly
- Convert the README to LF line endings
- Re-run `bun scripts/nav2readme.ts` after fixing; it rewrites between the two sentinels
Defensive patterns
Strategy: validation
Validate before calling
const readme = await Bun.file("README.md").text();
const quick = readme.indexOf("## Quick links\n");
if (quick === -1 || readme.indexOf("## Contributing\n", quick) === -1) {
throw new Error("README.md is missing a `## Contributing` heading after `## Quick links` — nav2readme would abort");
} Prevention
- Preserve section order: Quick links must precede Contributing
- Cover both sentinels in one pre-check before running the generator
When it happens
Trigger: The Contributing heading was renamed, removed, or moved above the Quick links section; CRLF line endings break the `\n` match just like the other sentinel.
Common situations: README reorganizations that move Contributing to a separate file; section renames (`## Getting involved`); Windows CRLF checkouts.
Related errors
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/af60f93a6cdc98cb.
Report an issue: GitHub.