ipfs/kubo · error

reading config from repo (%v)

Error message

reading config from repo (%v)

What it means

After opening the repo, doRotate calls repo.Config() to load the node configuration, which contains the identity being replaced. A failure reading or unmarshalling the config file is wrapped as "reading config from repo (%v)". This usually indicates a malformed or unreadable $IPFS_PATH/config.

Source

Thrown at core/commands/keystore.go:782

		if oldKey == "self" {
			return fmt.Errorf("keystore name for back up cannot be named 'self'")
		}
		return doRotate(os.Stdout, cctx.ConfigRoot, oldKey, algorithm, nBitsForKeypair, nBitsGiven)
	},
}

func doRotate(out io.Writer, repoRoot string, oldKey string, algorithm string, nBitsForKeypair int, nBitsGiven bool) error {
	// Open repo
	repo, err := fsrepo.Open(repoRoot)
	if err != nil {
		return fmt.Errorf("opening repo (%v)", err)
	}
	defer repo.Close()

	// Read config file from repo
	cfg, err := repo.Config()
	if err != nil {
		return fmt.Errorf("reading config from repo (%v)", err)
	}

	// Generate new identity
	var identity config.Identity
	if nBitsGiven {
		identity, err = config.CreateIdentity(out, []options.KeyGenerateOption{
			options.Key.Size(nBitsForKeypair),
			options.Key.Type(algorithm),
		})
	} else {
		identity, err = config.CreateIdentity(out, []options.KeyGenerateOption{
			options.Key.Type(algorithm),
		})
	}
	if err != nil {
		return fmt.Errorf("creating identity (%v)", err)
	}

View on GitHub (pinned to 329838acdf)

Solutions

  1. Validate the JSON: `python3 -m json.tool $IPFS_PATH/config` and fix syntax errors
  2. Check file permissions: `ls -l $IPFS_PATH/config` and chown/chmod as needed
  3. Restore from a backup copy of the config if one exists
  4. If Identity cannot be parsed, back up the file and re-examine it before rotating — rotate needs the old private key
Defensive patterns

Strategy: validation

Validate before calling

python3 -m json.tool "$IPFS_PATH/config" > /dev/null && echo "config OK" || echo "config is invalid JSON"

Try / catch

if err := doRotate(...); err != nil {
    if strings.Contains(err.Error(), "reading config from repo") {
        // restore config from backup before retrying
    }
}

Prevention

When it happens

Trigger: The config file contains invalid JSON; config file has wrong permissions (unreadable by current user); config file was truncated by an interrupted write; concurrent modification while reading.

Common situations: Manual edits to ~/.ipfs/config that broke JSON syntax (trailing commas, unquoted strings); running the command as a different user than the repo owner; disk-full during a previous config write.

Related errors


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