oven-sh/bun · error · Error

Could not find ## Quick links in README

Error message

Could not find ## Quick links in README

What it means

scripts/nav2readme.ts regenerates the guides listing inside the repo README.md by locating the literal sentinel heading `## Quick links\n` with indexOf. A -1 result means the heading is not present byte-for-byte, so the script cannot know where to inject the generated list.

Source

Thrown at scripts/nav2readme.ts:82

  let prevDirname = "";
  for (const { name, file } of files) {
    const dirname = path.basename(path.dirname(file));
    if (dirname !== prevDirname) {
      md += `\n- ${normalizeSectionName(dirname)} ` + "\n";
      prevDirname = dirname;
    }
    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) {

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Restore the exact heading `## Quick links` on its own line in README.md
  2. Normalize line endings to LF (`git config core.autocrlf false` and re-checkout, or dos2unix README.md)
  3. Keep the section order intact: Quick links must appear before Contributing so both sentinels resolve

Example fix

# before
## Quick Links\n\n<!-- guides -->\n\n## Contributing\n
# after
## Quick links\n\n<!-- regenerated -->\n\n## Contributing\n
Defensive patterns

Strategy: validation

Validate before calling

const readme = await Bun.file("README.md").text();
if (!readme.includes("## Quick links\n") || readme.includes("\r\n")) {
  throw new Error("README.md lost the `## Quick links` sentinel or has CRLF endings — fix before nav2readme");
}

Prevention

When it happens

Trigger: The heading was renamed or re-capitalized (`## Quick Links`), the README was restructured, or line endings changed to CRLF so the `\n` in the search string never matches. Any edit that removes the exact `## Quick links` line triggers it.

Common situations: Docs rewrites that rename sections; a git autocrlf checkout on Windows converting the README to CRLF; running the script against a different repository's README.

Related errors


AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16). Data as JSON: /api/errors/5e1e8d3f8b85e24a. Report an issue: GitHub.