ipfs/kubo · error
failed to load config: %q
Error message
failed to load config: %q
What it means
Wraps a failure of `r.Config()`, which loads and deserializes the entire repo config. getConfigWithAutoExpand needs the full config to resolve auto-expandable values (like ${IPFS_PATH} placeholders) after reading the raw key. Kubo throws it when the whole config file cannot be loaded, parsed as JSON, or validated against the config schema.
Source
Thrown at core/commands/config.go:581
return nil, fmt.Errorf("failed to get config value: %q", err)
}
return &ConfigField{
Key: key,
Value: value,
}, nil
}
func getConfigWithAutoExpand(r repo.Repo, key string) (*ConfigField, error) {
// First get the current value
value, err := r.GetConfigKey(key)
if err != nil {
return nil, fmt.Errorf("failed to get config value: %q", err)
}
// Load full config for resolution
fullCfg, err := r.Config()
if err != nil {
return nil, fmt.Errorf("failed to load config: %q", err)
}
// Expand auto values based on the key
expandedValue := fullCfg.ExpandConfigField(key, value)
return &ConfigField{
Key: key,
Value: expandedValue,
}, nil
}
func setConfig(r repo.Repo, key string, value any) (*ConfigField, error) {
err := r.SetConfigKey(key, value)
if err != nil {
return nil, fmt.Errorf("failed to set config value: %s (maybe use --json?)", err)
}
return getConfig(r, key)
}View on GitHub (pinned to 329838acdf)
Solutions
- Run `ipfs config show` — if it fails too, the config file itself is broken; inspect $IPFS_PATH/config.json with jq to find the JSON syntax error
- Restore the config from backup or re-generate defaults (`ipfs init` in a fresh dir and copy relevant fields)
- Fix type errors by using `ipfs config --json <key> <value>` instead of hand-editing
- Check file permissions/ownership of $IPFS_PATH/config.json
Example fix
// before (hand-edited config.json)
{"Datastore": {"StorageMax": "10GB",}}
// after: fix JSON, or set via CLI
ipfs config --json Datastore.StorageMax "10GB" Defensive patterns
Strategy: validation
Validate before calling
test -r "$IPFS_PATH/config" && jq empty "$IPFS_PATH/config" && echo "config OK" || echo "config missing or invalid JSON"
Try / catch
cfg, err := r.Config()
if err != nil {
return fmt.Errorf("config unreadable: %w", err)
} Prevention
- Validate config.json with jq after any hand edit
- Always set values via `ipfs config --json` instead of editing the file directly
- Keep a backup of $IPFS_PATH/config.json before changes
- Ensure the repo dir is readable by the user running the daemon/CLI
When it happens
Trigger: Calling `ipfs config get <key>` when $IPFS_PATH/config.json is missing, unreadable, contains invalid JSON, or fails schema validation (e.g. wrong types in a field).
Common situations: Hand-editing config.json and leaving trailing commas or wrong types (e.g. strings where booleans are expected); truncated config after a crash; running as a user without read permission on the repo.
Related errors
- could not read config: %w
- ipfs not initialized, please run 'ipfs init'
- failure to decode config: %w
- invalid flag value: %d
- failed to unmarshal %q into a flag: must be null/undefined,
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/40a18d1a644fcf84.
Report an issue: GitHub.