oven-sh/bun · error · BuildError

Invalid boolean value: ${v}

Error message

Invalid boolean value: ${v}

What it means

parseBool() in scripts/build.ts converts --flag=value strings into booleans for the config's bool fields. It accepts on/true/yes/1 and off/false/no/0 case-insensitively; any other token throws this BuildError, with the accepted spellings restated in the hint.

Source

Thrown at scripts/build.ts:575

    } 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;
    } else {
      throw new BuildError(`Unknown config field: --${rawKey}`, {
        hint: `Known fields: profile, target, ${[...boolFields, ...stringFields].sort().join(", ")}`,
      });
    }
  }

  return { profile, overrides, ninjaTargets, ninjaArgs, execArgs, configureOnly, quiet, configFile };
}

function parseBool(v: string): boolean {
  const lower = v.toLowerCase();
  if (["on", "true", "yes", "1"].includes(lower)) return true;
  if (["off", "false", "no", "0"].includes(lower)) return false;
  throw new BuildError(`Invalid boolean value: ${v}`, { hint: "Use on/off, true/false, yes/no, or 1/0" });
}

const USAGE = `\
Usage: bun scripts/build.ts [options] [exec-args...]

Options:
  --profile=<name>        Build profile (default: debug)
                          Profiles: debug, debug-local, debug-no-asan,
                                    release, release-local, release-asan,
                                    release-assertions, ci-*,
                                    windows-{x64,arm64}[-release] (cross-compile
                                    from a non-Windows host)
  --<field>=<value>       Override a config field. Boolean fields take
                          on/off/true/false/yes/no/1/0.
                          Fields: asan, lto, assertions, logs, baseline,
                                  canary, valgrind, webkit (prebuilt|local),
                                  local-deps (name=path[,name=path] — build a
                                  vendored dep from a local checkout),

View on GitHub (pinned to 8c5296ac45)

Solutions

  1. Use one of the listed literals: on/off, true/false, yes/no, or 1/0 (case-insensitive)
  2. If the value comes from a variable, echo it first to catch empty content
  3. Re-read the hint text — it restates the accepted set verbatim

Example fix

# before
$ bun bd --asan=maybe
BuildError: Invalid boolean value: maybe

# after
$ bun bd --asan=off
Defensive patterns

Strategy: validation

Validate before calling

const BOOL_LITERALS = ["on", "true", "yes", "1", "off", "false", "no", "0"];
const v = process.argv.find(a => a.startsWith("--ci="))?.slice(5);
if (v !== undefined && !BOOL_LITERALS.includes(v.toLowerCase())) {
  console.error(`--ci=${v} is not boolean; use ${BOOL_LITERALS.join("/")}`);
  process.exit(2);
}

Type guard

const isBoolLiteral = (v: string) =>
  ["on", "true", "yes", "1", "off", "false", "no", "0"].includes(v.toLowerCase());

Prevention

When it happens

Trigger: --asan=maybe, --verbose=ENABLE, --ci=2, or an empty value (--ci=) — none are in the accepted literal lists.

Common situations: Copy-pasting CMake-style values that do not translate; values interpolated from environment variables that turn out empty or unexpected; quoting mishaps in CI YAML.

Related errors


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