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

  1. 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
  2. Restore the config from backup or re-generate defaults (`ipfs init` in a fresh dir and copy relevant fields)
  3. Fix type errors by using `ipfs config --json <key> <value>` instead of hand-editing
  4. 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

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


AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03). Data as JSON: /api/errors/40a18d1a644fcf84. Report an issue: GitHub.