grafana/k6 · error
couldn't load the configuration from %q: %w
Error message
couldn't load the configuration from %q: %w
What it means
Emitted by readDiskConfig when the k6 config file (default ~/.config/loadimpact/k6.json or the path given by --config) was found by Stat but could not be read via fsext.ReadFile. This is an I/O-level failure after the existence check succeeded: permission denied, a dangling symlink, a directory, or the file disappearing between Stat and Read.
Source
Thrown at internal/cmd/config.go:148
// readDiskConfig reads the configuration file from the supplied filesystem and returns it or
// an error. The only situation in which an error won't be returned is if the
// user didn't explicitly specify a config file path and the default config file
// doesn't exist.
func readDiskConfig(gs *state.GlobalState) (Config, error) {
// Try to see if the file exists in the supplied filesystem
if _, err := gs.FS.Stat(gs.Flags.ConfigFilePath); err != nil {
if errors.Is(err, fs.ErrNotExist) && gs.Flags.ConfigFilePath == gs.DefaultFlags.ConfigFilePath {
// If the file doesn't exist, but it was the default config file (i.e. the user
// didn't specify anything), silence the error
err = nil
}
return Config{}, err
}
data, err := fsext.ReadFile(gs.FS, gs.Flags.ConfigFilePath)
if err != nil {
return Config{}, fmt.Errorf("couldn't load the configuration from %q: %w", gs.Flags.ConfigFilePath, err)
}
var conf Config
err = json.Unmarshal(data, &conf)
if err != nil {
return Config{}, fmt.Errorf("couldn't parse the configuration from %q: %w", gs.Flags.ConfigFilePath, err)
}
return conf, nil
}
// Permissions for the on-disk config file and its containing directory.
// The config can contain the Grafana Cloud API token (collectors.cloud.token),
// so it must not be readable by other local users.
const (
configFileMode = fs.FileMode(0o600)
configDirMode = fs.FileMode(0o700)
)
// writeDiskConfig serializes the configuration to a JSON file and writes it in the suppliedView on GitHub (pinned to 93accf6570)
Solutions
- Check permissions on the path shown in the message: `ls -l <path>` and ensure the current user can read it (the file may contain a cloud token, k6 expects it 0o600)
- Fix ownership/permissions: `chmod 600 <path> && chown $USER <path>`
- Verify the path is a regular file: `file <path>`; replace directories/broken symlinks with a valid JSON file
- If the config is not needed, remove or correct the --config flag / K6_CONFIG env var pointing at the bad path
Example fix
# before $ k6 run script.js --config /etc/k6/k6.json # error: couldn't load the configuration from "/etc/k6/k6.json": open /etc/k6/k6.json: permission denied # after $ sudo chown $USER /etc/k6/k6.json && chmod 600 /etc/k6/k6.json $ k6 run script.js --config /etc/k6/k6.json
Defensive patterns
Strategy: validation
Validate before calling
# Guard before running k6: config path readable and a regular file
cfg="${K6_CONFIG:-$HOME/.config/loadimpact/k6.json}"
if [ -e "$cfg" ]; then
[ -f "$cfg" ] && [ -r "$cfg" ] || { echo "config $cfg not readable"; exit 1; }
fi Prevention
- Keep k6 config owned by the runtime user with mode 600 (it may hold a cloud token)
- Avoid pointing --config at paths on flaky mounts or directories
- When baking container images, chmod/chown the config in the same layer it is created
When it happens
Trigger: Running any k6 command with a --config path that exists but is unreadable (chmod 000, owned by another user), points at a directory, or is a broken symlink. Note: a missing default config file is silently ignored (the code nils out fs.ErrNotExist for the default path), so absence alone never triggers this.
Common situations: Config file permissions changed by a privileged install or a restore from backup; k6 run under a different user/service account than the one that owns the config; --config pointing to a path inside an unmounted volume; restrictive umask plus tooling that replaced the file with a directory.
Related errors
- failed to load the configuration file from the local file sy
- persisting screenshot: %w
- open() failed, unable to verify if %q exists; reason: %w
- open() failed, unable to verify if %q is a directory; reason
- open() failed; reason: unable to access the file system
AI-assisted analysis of grafana/k6@93accf6570 (2026-08-15).
Data as JSON: /api/errors/42ed3457ebc5b412.
Report an issue: GitHub.