Skip to content
Latchkey

Bun "bunfig.toml" Configuration Error in CI

Bun could not parse or apply bunfig.toml. The file has invalid TOML, a key in the wrong section, or a registry/scope block Bun cannot use - so the command that reads config fails.

What this error means

A bun install/bun test/bun run command fails early complaining about the config - a TOML parse error, an unknown/misplaced key, or an unusable registry entry in bunfig.toml.

bun output
error: failed to parse bunfig.toml: expected ']' to close table header
  at bunfig.toml:6
# or
error: invalid registry URL in [install.scopes]

Common causes

Invalid TOML syntax

A malformed table header, unquoted value, or stray character makes bunfig.toml unparseable, so Bun cannot read any config.

Key in the wrong section

Config under the wrong table (e.g. a test option outside [test], a registry outside [install]) is ignored or rejected.

How to fix it

Validate and correct the TOML

Fix the syntax and place keys in their proper sections.

bunfig.toml
# bunfig.toml
[install]
registry = "https://registry.npmjs.org"

[install.scopes]
"@my-org" = { url = "https://npm.pkg.github.com", token = "$GH_TOKEN" }

[test]
preload = ["./test/setup.ts"]

Confirm which config Bun loads

  1. Bun reads bunfig.toml from the project root (and a global one) - make sure CI runs where the file is.
  2. Remove duplicate/conflicting keys across global and local configs.
  3. Keep secrets as $ENV references, not committed literals.

How to prevent it

  • Lint/validate bunfig.toml as TOML in CI.
  • Keep registry/scope/test keys in their correct sections.
  • Reference tokens via env vars, never commit them.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →