ipfs/kubo · error

failed to read config: %w

Error message

failed to read config: %w

What it means

KeyAPI(name.go).Publish in AllowDelegated mode reads the node config to find configured delegated IPNS publishers. If repo.Config() fails (config unreadable/corrupt/locked), the error is wrapped with this message.

Source

Thrown at core/coreapi/name.go:53

	options, err := caopts.NamePublishOptions(opts...)
	if err != nil {
		return ipns.Name{}, err
	}
	span.SetAttributes(
		attribute.Bool("allowoffline", options.AllowOffline),
		attribute.String("key", options.Key),
		attribute.Float64("validtime", options.ValidTime.Seconds()),
	)
	if options.TTL != nil {
		span.SetAttributes(attribute.Float64("ttl", options.TTL.Seconds()))
	}

	// Handle different publishing modes
	if options.AllowDelegated {
		// AllowDelegated mode: check if delegated publishers are configured
		cfg, err := api.repo.Config()
		if err != nil {
			return ipns.Name{}, fmt.Errorf("failed to read config: %w", err)
		}
		delegatedPublishers := cfg.DelegatedPublishersWithAutoConf()
		if len(delegatedPublishers) == 0 {
			return ipns.Name{}, errors.New("no delegated publishers configured: add Ipns.DelegatedPublishers or use --allow-offline for local-only publishing")
		}
		// For allow-delegated mode, we only require that we have delegated publishers configured
		// The node doesn't need P2P connectivity since we're using HTTP publishing
	} else {
		// Normal mode: check online status with allow-offline flag
		err = api.checkOnline(options.AllowOffline)
		if err != nil {
			return ipns.Name{}, err
		}
	}

	k, err := keylookup(api.privateKey, api.repo.Keystore(), options.Key)
	if err != nil {
		return ipns.Name{}, err

View on GitHub (pinned to 329838acdf)

Solutions

  1. Check the wrapped cause (%w) for the underlying read failure and fix it (permissions, JSON syntax).
  2. Verify IPFS_PATH points at an initialized repo: run `ipfs config show`.
  3. Restore the config from backup or re-run `ipfs init` in a fresh path if the config is unrecoverable.

Example fix

// before
export IPFS_PATH=/wrong/path
ipfs name publish --delegated <cid>
// after
export IPFS_PATH=$HOME/.ipfs
ipfs config show >/dev/null && ipfs name publish --delegated <cid>
Defensive patterns

Strategy: try-catch

Validate before calling

if _, err := cfgRoot.Config(); err != nil {
    return fmt.Errorf("repo config unreadable, fix before publishing: %w", err)
}

Try / catch

n, err := api.Name().Publish(ctx, p, opts.AllowDelegated(true))
var perr *fs.PathError
if errors.As(err, &perr) {
    // permission/path problem on the config file; fix IPFS_PATH or permissions
}

Prevention

When it happens

Trigger: Publishing with AllowDelegated=true while the repo config cannot be read, e.g. corrupted config file, permission denied, or concurrent repo lock issues.

Common situations: Wrong IPFS_PATH pointing at a directory without a config; config file with invalid JSON; 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/1e1b7e9ed980870e. Report an issue: GitHub.