ipfs/kubo · critical

identity was not set in config (was 'ipfs init' run?)

Error message

identity was not set in config (was 'ipfs init' run?)

What it means

Kubo requires a cryptographic identity in the repo config; the PeerID string is empty, meaning the Identity section is missing. The fx graph for the node cannot be built without a peer identity, so node construction fails immediately with this message hinting that `ipfs init` was never run (or the config lost Identity).

Source

Thrown at core/node/groups.go:273

		fx.Provide(RepoConfig),
		fx.Provide(Datastore),
		fx.Provide(BaseBlockstoreCtor(
			cacheOpts,
			cfg.Datastore.HashOnRead,
			cfg.Datastore.WriteThrough.WithDefault(config.DefaultWriteThrough),
			cfg.Provide.Strategy.WithDefault(config.DefaultProvideStrategy),
		)),
		finalBstore,
	)
}

// Identity groups units providing cryptographic identity
func Identity(cfg *config.Config) fx.Option {
	// PeerID

	cid := cfg.Identity.PeerID
	if cid == "" {
		return fx.Error(errors.New("identity was not set in config (was 'ipfs init' run?)"))
	}
	if len(cid) == 0 {
		return fx.Error(errors.New("no peer ID in config! (was 'ipfs init' run?)"))
	}

	id, err := peer.Decode(cid)
	if err != nil {
		return fx.Error(fmt.Errorf("peer ID invalid: %s", err))
	}

	// Private Key

	if cfg.Identity.PrivKey == "" {
		return fx.Options( // No PK (usually in tests)
			fx.Provide(PeerID(id)),
			fx.Provide(libp2p.Peerstore),
		)
	}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Run `ipfs init` in the configured IPFS_PATH to create a fresh identity
  2. Verify IPFS_PATH points at the intended repo (`ipfs repo stat`)
  3. Restore the Identity section (PeerID and PrivKey) from a backup of the original config

Example fix

// before
IPFS_PATH=/nonexistent ipfs daemon
// Error: identity was not set in config (was 'ipfs init' run?)
// after
export IPFS_PATH=~/.ipfs
ipfs init   # only if the repo does not exist
ipfs daemon
Defensive patterns

Strategy: validation

Validate before calling

if cfg.Identity == nil || cfg.Identity.PeerID == "" {
	// run `ipfs init` or load the correct repo before constructing the node
	return errors.New("repo missing Identity.PeerID; run ipfs init")
}

Prevention

When it happens

Trigger: `cfg.Identity.PeerID == ""` when the Identity fx group builds — empty repo, config file replaced, or Identity key deleted.

Common situations: Running kubo without `ipfs init`; pointing IPFS_PATH at an empty or wrong directory; manually editing config.json and removing Identity; restoring only part of a repo backup.

Related errors


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