denoland/deno · error

failed to write startup order {}: {error}

Error message

failed to write startup order {}: {error}

What it means

Build-script panic in cli/build.rs. The decoded order contents are copied to a fixed path in cargo's OUT_DIR (startup-order-<target>.order) so the linker argument never changes (full-LTO output is sensitive to the order-file path). std::fs::write to that destination fails on a full disk, a read-only or missing OUT_DIR, or permission errors, panicking with the destination path.

Source

Thrown at cli/build.rs:498

      panic!("failed to read startup order {}: {error}", source.display())
    });
    zstd::stream::decode_all(compressed.as_slice()).unwrap_or_else(|error| {
      panic!(
        "failed to decompress startup order {}: {error}",
        source.display()
      )
    })
  } else {
    std::fs::read(&source).unwrap_or_else(|error| {
      panic!("failed to read startup order {}: {error}", source.display())
    })
  };

  // Always use the same linker path for generated orders. Full-LTO output can
  // change when only the order-file path changes.
  let order_file = out_dir.join(format!("startup-order-{target}.order"));
  std::fs::write(&order_file, contents).unwrap_or_else(|error| {
    panic!(
      "failed to write startup order {}: {error}",
      order_file.display()
    )
  });

  let contents = std::fs::read_to_string(&order_file).unwrap_or_else(|error| {
    panic!(
      "failed to validate startup order {}: {error}",
      order_file.display()
    )
  });
  let symbol_count = contents
    .lines()
    .filter(|line| !line.is_empty() && !line.starts_with('#'))
    .count();
  if symbol_count < 1_000 {
    panic!(
      "startup order {} has only {symbol_count} symbols",

View on GitHub (pinned to 9ad36f7a2c)

Solutions

  1. Free space or raise the disk quota on the volume holding target/, then rebuild
  2. Fix permissions: `chmod -R u+w target/` or move CARGO_TARGET_DIR to a writable location
  3. Disable startup ordering (`unset DENO_USE_STARTUP_ORDER`) if you only need a build, not the optimization
Defensive patterns

Strategy: validation

Validate before calling

df -h "${CARGO_TARGET_DIR:-$PWD/target}" | tail -1   # ensure space
mkdir -p "${CARGO_TARGET_DIR:-$PWD/target}" && touch "${CARGO_TARGET_DIR:-$PWD/target}/.w" || { echo 'target dir not writable'; exit 2; }

Prevention

When it happens

Trigger: Building with startup ordering enabled when the filesystem holding target/ is full (ENOSPC), OUT_DIR was made read-only, or the build runs under a sandbox/containers with a no-write overlay for the build directory.

Common situations: CI runners with exhausted disk quotas; devcontainers where /workspace is a read-only mount; antivirus or macOS SIP-protected paths blocking writes into target/release/build/...

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20). Data as JSON: /api/errors/c783e540247eec9f. Report an issue: GitHub.