{"record":{"id":"135affca2e98c6f4","repo":"oven-sh/bun","slug":"failed-to-build-the-pty-runner-with-cc-pty-st","errorCode":null,"errorMessage":"failed to build the pty runner with ${cc}\n${pty.stderr}","messagePattern":"failed to build the pty runner with (.+?)\n(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/orderfile/generate.ts","lineNumber":211,"sourceCode":"  const bunProfile = join(buildDir, options.exeName ?? \"bun-profile\");\n  if (!existsSync(bunProfile)) {\n    throw new Error(`${bunProfile} not found — build it first (bun run build:release)`);\n  }\n\n  const scratch = mkdtempSync(join(tmpdir(), \"bun-orderfile-\"));\n  try {\n    // ── Build the tracer and the pty runner ───────────────────────────────────\n    const tracer = join(scratch, darwin ? \"functrace.dylib\" : \"functrace.so\");\n    const ptyrun = join(scratch, \"ptyrun\");\n    const cc = process.env.CC || \"cc\";\n    const build = runCommand(\n      darwin\n        ? [cc, \"-O2\", \"-dynamiclib\", \"-fPIC\", \"-o\", tracer, join(here, \"functrace.c\")]\n        : [cc, \"-O2\", \"-shared\", \"-fPIC\", \"-o\", tracer, join(here, \"functrace.c\"), \"-ldl\", \"-lpthread\"],\n    );\n    if (build.status !== 0) throw new Error(`failed to build the tracer with ${cc}\\n${build.stderr}`);\n    const pty = runCommand([cc, \"-O2\", \"-o\", ptyrun, join(here, \"ptyrun.c\"), ...(darwin ? [] : [\"-lutil\"])]);\n    if (pty.status !== 0) throw new Error(`failed to build the pty runner with ${cc}\\n${pty.stderr}`);\n\n    // ── Symbol table and function starts ──────────────────────────────────────\n    const symbols = readSymbolTable(bunProfile);\n    const startsPath = join(scratch, \"starts.bin\");\n    writeStarts(\n      startsPath,\n      [...symbols.keys()].sort((a, b) => a - b),\n    );\n\n    // ── Representative workloads ──────────────────────────────────────────────\n    // Order matters: earlier workloads get the densest placement, so the plain\n    // runtime startup path comes first.\n    const fixtures = join(scratch, \"fixtures\");\n    mkdirSync(join(fixtures, \"tests\"), { recursive: true });\n    writeFileSync(\n      join(fixtures, \"hello.ts\"),\n      `const greet = (name: string): string => \\`hi \\${name}\\`;\\nconsole.log(greet(\"world\"));\\n`,\n    );","sourceCodeStart":193,"sourceCodeEnd":229,"githubUrl":"https://github.com/oven-sh/bun/blob/8c5296ac459e8252d3cd702f3fbcbb0c249d95d5/scripts/orderfile/generate.ts#L193-L229","documentation":"Compiling ptyrun.c — the pseudo-terminal runner that executes interactive workloads under a real tty — failed, with compiler stderr appended. On Linux it additionally links -lutil for the pty APIs, so a missing util library is a platform-specific cause.","triggerScenarios":"Same toolchain problems as the tracer build (no compiler, bad CC), plus on Linux a missing/unavailable libutil; on macOS an SDK mismatch affecting pty headers.","commonSituations":"Minimal containers lacking libc development files; broken CC overrides; toolchain half-installed so functrace.c compiled but ptyrun.c did not.","solutions":["Read the appended stderr — it distinguishes a missing -lutil from a compile error","Install/repair the C toolchain (build-essential / Xcode CLT) including libc dev pieces","Set CC to a known-good compiler and re-run; scratch rebuilds are cheap"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"import { spawnSync } from \"node:child_process\";\n\n// Probe both compilations cheaply before the full run.\nconst probe = spawnSync(cc, [\"-O2\", \"-o\", \"/tmp/ptyrun-probe\", \"ptyrun.c\", ...(darwin ? [] : [\"-lutil\"])], { cwd: here });\nif (probe.status !== 0) throw new Error(`pty runner would fail to build:\\n${probe.stderr}`);","typeGuard":null,"tryCatchPattern":"try {\n  buildPtyRunner();\n} catch (err) {\n  if (/failed to build the pty runner/.test(String(err))) {\n    console.error(\"Check -lutil availability on Linux and the C toolchain; stderr above names the cause\");\n  }\n  throw err;\n}","preventionTips":["Install libc development packages alongside the compiler in containers used for tracing","Keep CC/NM overrides consistent within one environment"],"tags":["compiler","toolchain","orderfile","pty","linker"],"backgroundTag":null,"analyzedSha":"8c5296ac459e8252d3cd702f3fbcbb0c249d95d5","analyzedAt":"2026-08-16T08:01:58.794Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}