grafana/k6 · error
failed to load the configuration file from the local file sy
Error message
failed to load the configuration file from the local file system: %w
What it means
Top-level wrapper produced by getConsolidatedConfig, the function that merges all configuration layers (CLI > env > runner options > file config). It fires when readDiskConfig fails and attaches exit code InvalidConfig (104), so besides the message the k6 process exits with a specific code. The underlying error is one of the two readDiskConfig failures: unreadable file (I/O) or unparseable JSON.
Source
Thrown at internal/cmd/config.go:221
})
return conf, err
}
// getConsolidatedConfig assemble the final consolidated configuration from all of the different sources:
// - start with the CLI-provided options to get shadowed (non-Valid) defaults in there
// - add the global file config options
// - add the Runner-provided options (they may come from Bundle too if applicable)
// - add the environment variables
// - merge the user-supplied CLI flags back in on top, to give them the greatest priority
// - set some defaults if they weren't previously specified
// TODO: add better validation, more explicit default values and improve consistency between formats
// TODO: accumulate all errors and differentiate between the layers?
func getConsolidatedConfig(
gs *state.GlobalState, cliConf Config, runnerOpts lib.Options, flags *features.Flags,
) (Config, error) {
fileConf, err := readDiskConfig(gs)
if err != nil {
err = fmt.Errorf("failed to load the configuration file from the local file system: %w", err)
return Config{}, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)
}
envConf, err := readEnvConfig(gs.Env)
if err != nil {
return Config{}, errext.WithExitCodeIfNone(err, exitcodes.InvalidConfig)
}
conf := cliConf.Apply(fileConf)
warnOnShortHandOverride(conf.Options, runnerOpts, "script", gs.Logger)
conf = conf.Apply(Config{Options: runnerOpts})
warnOnShortHandOverride(conf.Options, envConf.Options, "env", gs.Logger)
conf = conf.Apply(envConf)
warnOnShortHandOverride(conf.Options, cliConf.Options, "cli", gs.Logger)
conf = conf.Apply(cliConf)View on GitHub (pinned to 93accf6570)
Solutions
- Read the wrapped (inner) error in the output — it is either "couldn't load the configuration from %q" (I/O) or "couldn't parse the configuration from %q" (JSON) and names the exact file
- For I/O failures: fix permissions/ownership so the current user can read the file
- For parse failures: validate with `jq . <file>` and fix the JSON syntax at the reported offset
- Temporary workaround: run with an explicit empty config `--config /dev/null` (or unset K6_CONFIG) to confirm the rest of the setup is fine
Example fix
# before $ k6 run script.js # error: failed to load the configuration file from the local file system: couldn't parse the configuration from "k6.json": invalid character '}' looking for beginning of value # after $ jq . k6.json # locate & fix syntax, then re-run $ k6 run script.js
Defensive patterns
Strategy: validation
Validate before calling
# Pre-flight the whole config surface: readable + valid JSON
k6 inspect -o execution-script script.js >/dev/null 2>cfg.err || true
grep -q 'failed to load the configuration file' cfg.err && { echo 'fix k6 config first'; exit 1; } Prevention
- Treat the k6 config file like code: lint it in CI when it changes
- Watch exit code 104 (InvalidConfig) in pipelines as the signal of config-layer failures
- Keep --config explicit in automation so the default-path fallback can't mask which file is in play
When it happens
Trigger: Any command that consolidates config (k6 run, k6 cloud run, k6 archive, ...) while the config file from --config/K6_CONFIG/default path is either unreadable (permissions, directory, dangling symlink) or contains invalid JSON.
Common situations: Same real-world causes as the readDiskConfig errors: permission changes, malformed hand-edits, CI-baked broken configs. Users see it as the outermost message, so the fix requires reading the wrapped inner error naming the file and JSON offset.
Related errors
- failed to load the configuration file from the local file sy
- couldn't load the configuration from %q: %w
- couldn't parse the configuration from %q: %w
- 98
- 99
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/e91d5dbfc2a2379d.
Report an issue: GitHub.