{"record":{"id":"c5c7dfd77360561d","repo":"denoland/deno","slug":"failed-to-validate-startup-order-error","errorCode":null,"errorMessage":"failed to validate startup order {}: {error}","messagePattern":"failed to validate startup order (.+?): (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"cli/build.rs","lineNumber":505,"sourceCode":"    })\n  } else {\n    std::fs::read(&source).unwrap_or_else(|error| {\n      panic!(\"failed to read startup order {}: {error}\", source.display())\n    })\n  };\n\n  // Always use the same linker path for generated orders. Full-LTO output can\n  // change when only the order-file path changes.\n  let order_file = out_dir.join(format!(\"startup-order-{target}.order\"));\n  std::fs::write(&order_file, contents).unwrap_or_else(|error| {\n    panic!(\n      \"failed to write startup order {}: {error}\",\n      order_file.display()\n    )\n  });\n\n  let contents = std::fs::read_to_string(&order_file).unwrap_or_else(|error| {\n    panic!(\n      \"failed to validate startup order {}: {error}\",\n      order_file.display()\n    )\n  });\n  let symbol_count = contents\n    .lines()\n    .filter(|line| !line.is_empty() && !line.starts_with('#'))\n    .count();\n  if symbol_count < 1_000 {\n    panic!(\n      \"startup order {} has only {symbol_count} symbols\",\n      order_file.display()\n    );\n  }\n\n  let order_file = order_file.canonicalize().unwrap();\n  match target.as_str() {\n    \"aarch64-apple-darwin\" => println!(","sourceCodeStart":487,"sourceCodeEnd":523,"githubUrl":"https://github.com/denoland/deno/blob/9ad36f7a2cce60488e6ec52283efb32efddaf93a/cli/build.rs#L487-L523","documentation":"Build-script panic in cli/build.rs. Immediately after writing the copied order file, the script reads it back with fs::read_to_string to validate its contents (counting non-empty, non-comment lines). read_to_string requires valid UTF-8; a non-UTF-8 order file (binary garbage, wrong encoding, LZ4/gzip bytes despite the extension) makes this read fail and panics as \"failed to validate startup order <path>\".","triggerScenarios":"The decoded order-file bytes are not UTF-8 text — e.g. the file is still compressed under a non-.zst name, is UTF-16 output from a PowerShell redirect, or the .zst decoded to something that is not an order list.","commonSituations":"Toolchains on Windows writing UTF-16 with BOM; a generation script emitting the wrong format; an artifact naming mismatch (gzip'd file named .order).","solutions":["Check encoding: `file \"$DENO_STARTUP_ORDER_FILE\"` — it must be ASCII/UTF-8 text, one symbol per line","If the payload is another compression format, decompress it and supply the raw text file (or properly .zst-compress it)","Regenerate the order file with the supported generator so it is plain text lines with optional # comments"],"exampleFix":"# before\nDENO_STARTUP_ORDER_FILE=deno.order.gz    # gz bytes, not utf-8\n# after\ngunzip -c deno.order.gz > deno.order\nDENO_STARTUP_ORDER_FILE=$PWD/deno.order","handlingStrategy":"validation","validationCode":"file \"$DENO_STARTUP_ORDER_FILE\"            # expect: ASCII text / UTF-8\niconv -f utf-8 -t utf-8 \"$DENO_STARTUP_ORDER_FILE\" >/dev/null || echo 'not valid UTF-8'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Generate order files as plain UTF-8/ASCII text, one symbol per line","On Windows avoid PowerShell redirects that emit UTF-16 (use cmd redirect or set output encoding)"],"tags":["build-script","utf-8","encoding","validation","startup-order"],"backgroundTag":"non-utf8-file","analyzedSha":"9ad36f7a2cce60488e6ec52283efb32efddaf93a","analyzedAt":"2026-08-20T13:07:44.778Z","schemaVersion":2},"datasetVersion":"2026-08-31T04:17:50.494Z"}