oven-sh/bun · error · BuildError

--${rawKey} requires a value

Error message

--${rawKey} requires a value

What it means

In scripts/build.ts arg parsing, a recognized flag was given without `=`, so the parser consumes the next argv entry as its value — but argv ended first. The error names the flag via rawKey so you know which operand is missing.

Source

Thrown at scripts/build.ts:542

      continue;
    }
    const rawKey = eq[1]!;
    const key = rawKey.replace(/-([a-z])/g, (_, c: string) => c.toUpperCase());
    const isOurs =
      key === "profile" || key === "target" || key === "configFile" || boolFields.has(key) || stringFields.has(key);

    let value = eq[2];
    if (value === undefined) {
      // No `=`. If this is one of our flags, consume next arg as value.
      // If not (e.g. --print, --watch), it's a bun-debug flag → exec args.
      if (!isOurs) {
        execArgs.push(arg);
        inExec = true;
        continue;
      }
      value = argv[++i];
      if (value === undefined) {
        throw new BuildError(`--${rawKey} requires a value`);
      }
    }

    if (key === "target") {
      ninjaTargets.push(value);
      continue;
    }
    if (key === "configFile") {
      configFile = value;
      configureOnly = true;
      continue;
    }
    if (key === "profile") {
      profile = value;
    } else if (boolFields.has(key)) {
      (overrides as Record<string, boolean>)[key] = parseBool(value);
    } else if (stringFields.has(key)) {
      (overrides as Record<string, string>)[key] = value;

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Supply the value: --profile=release (or `--profile release`)
  2. Check nothing after the flag was swallowed by quoting or line-continuation
  3. Consult the USAGE block for the flag's expected value

Example fix

# before
$ bun bd --profile
BuildError: --profile requires a value

# after
$ bun bd --profile=release
Defensive patterns

Strategy: validation

Validate before calling

const NEEDS_VALUE = new Set(["profile", "configFile" /*, ...boolFields, ...stringFields */]);
for (let i = 2; i < process.argv.length; i++) {
  const a = process.argv[i];
  if (a.startsWith("--") && !a.includes("=") && NEEDS_VALUE.has(a.slice(2)) && i + 1 >= process.argv.length) {
    console.error(`${a} requires a value`);
    process.exit(2);
  }
}

Prevention

When it happens

Trigger: bun bd --profile with nothing after it; bun scripts/build.ts --config-file as the last token; a shell line whose value token was lost to quoting or line-wrapping.

Common situations: Truncated copy-pasted commands; line continuations eating the value; typos where the value was placed before the flag.

Related errors


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