{"record":{"id":"3119cab750bf2eb0","repo":"vercel/next.js","slug":"missing-next-bin-build-next-js-first-pnpm-f","errorCode":null,"errorMessage":"Missing ${NEXT_BIN}. Build Next.js first (pnpm --filter=next build).","messagePattern":"Missing (.+?)\\. Build Next\\.js first \\(pnpm --filter=next build\\)\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"bench/render-pipeline/benchmark.ts","lineNumber":290,"sourceCode":"): Promise<void> {\n  const child = spawn(command, args, {\n    cwd,\n    env,\n    stdio: 'inherit',\n  })\n  const [code] = (await once(child, 'exit')) as [number | null]\n  if (code !== 0) {\n    throw new Error(\n      `Command failed: ${command} ${args.join(' ')} (exit ${code})`\n    )\n  }\n}\n\nasync function ensureNextBuilt() {\n  try {\n    await access(NEXT_BIN)\n  } catch {\n    throw new Error(\n      `Missing ${NEXT_BIN}. Build Next.js first (pnpm --filter=next build).`\n    )\n  }\n}\n\nasync function waitForServerReady(\n  url: string,\n  timeoutMs: number,\n  serverDied?: () => boolean\n): Promise<void> {\n  const start = performance.now()\n  while (performance.now() - start < timeoutMs) {\n    // Without this check, a server that dies on startup (e.g. EADDRINUSE\n    // against a stale server on the same port) is indistinguishable from\n    // a slow one — worse, a 200 from whatever else owns the port would\n    // pass, and the run would silently measure the wrong server.\n    if (serverDied?.()) {\n      throw new Error(","sourceCodeStart":272,"sourceCodeEnd":308,"githubUrl":"https://github.com/vercel/next.js/blob/0ae8c72462952df163f1b1e0726641bc5b40dc93/bench/render-pipeline/benchmark.ts#L272-L308","documentation":"Thrown by ensureNextBuilt (benchmark.ts:290) when packages/next/dist/bin/next (NEXT_BIN) is not accessible. The render-pipeline benchmark drives that binary directly to build and start the fixture, so it must exist locally. It cannot use a globally-installed `next` because it needs the locally-built framework (the whole point is benchmarking in-tree changes).","triggerScenarios":"Calling runMinimalServerBenchmarks/runE2EBenchmarks (both call ensureNextBuilt first) when packages/next/dist/bin/next is absent — e.g. on a fresh checkout, after `git clean -fdx`, after switching branches without rebuilding, or when only a partial build ran.","commonSituations":"Fresh clone without bootstrap; branch switch that invalidated the dist output; `pnpm install` ran but `pnpm --filter=next build` did not; dist was deleted by a clean script.","solutions":["Build Next.js: `pnpm --filter=next build` (as the message says), then re-run the benchmark.","On branch switch or fresh checkout, run a full bootstrap (pnpm install + pnpm build-all) per the repo's dev guide.","Confirm the file exists: ls packages/next/dist/bin/next.","If you intentionally only changed non-Next.js files, you still need a one-time build to produce NEXT_BIN."],"exampleFix":"# before — error on benchmark start\n#   Missing .../packages/next/dist/bin/next. Build Next.js first ...\n\n# fix\npnpm --filter=next build\npnpm bench:render-pipeline --scenario=e2e","handlingStrategy":"validation","validationCode":"import { accessSync, constants } from 'node:fs'\nimport { resolve } from 'node:path'\n\nconst NEXT_BIN = resolve(REPO_ROOT, 'packages/next/dist/bin/next')\nfunction ensureNextBuiltOrHint() {\n  try { accessSync(NEXT_BIN, constants.X_OK) }\n  catch {\n    throw new Error(`Missing ${NEXT_BIN}. Run: pnpm --filter=next build`)\n  }\n}","typeGuard":"import { existsSync } from 'node:fs'\nfunction nextBinExists(bin: string): boolean {\n  return existsSync(bin)\n}","tryCatchPattern":"try {\n  await ensureNextBuilt()\n} catch (err) {\n  console.error((err as Error).message)\n  console.error('Run: pnpm --filter=next build   (or pnpm build-all for a full bootstrap)')\n  process.exit(2)\n}","preventionTips":["Always run `pnpm --filter=next build` (or pnpm build-all) after checkout/branch-switch before benchmarking.","Add a one-line bootstrap check at the start of CI scripts.","Don't delete packages/next/dist between build and benchmark.","Remember the benchmark needs the locally-built next, not a global install."],"tags":["build","setup","render-pipeline","missing-binary","bootstrap"],"analyzedSha":"0ae8c72462952df163f1b1e0726641bc5b40dc93","analyzedAt":"2026-08-06T19:44:29.143Z","schemaVersion":2},"datasetVersion":"2026-08-07T02:17:10.218Z"}