ipfs/kubo · error
opening repo (%v)
Error message
opening repo (%v)
What it means
doRotate opens the IPFS repository (fsrepo.Open) to read the config and access the keystore. If the repo cannot be opened — because it is already locked by a running daemon, does not exist, or is on an incompatible version — the error is wrapped as "opening repo (%v)". The underlying fsrepo error is preserved in the message.
Source
Thrown at core/commands/keystore.go:775
cctx := env.(*oldcmds.Context)
nBitsForKeypair, nBitsGiven := req.Options[keyStoreSizeOptionName].(int)
algorithm, _ := req.Options[keyStoreTypeOptionName].(string)
oldKey, ok := req.Options[oldKeyOptionName].(string)
if !ok {
return fmt.Errorf("keystore name for backing up old key must be provided")
}
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{View on GitHub (pinned to 329838acdf)
Solutions
- Stop the daemon first: `ipfs shutdown` or kill the process, then retry rotate
- Verify IPFS_PATH points at the initialized repo (`ipfs repo version`, `ls $IPFS_PATH`)
- If a migration is required, run `ipfs repo migrate` (or the matching binary version) before rotating
- Remove a stale $IPFS_PATH/repo.lock only if no daemon is running
Example fix
// before ipfs key rotate --old-key=old # daemon running -> lock error // after ipfs shutdown ipfs key rotate --old-key=old
Defensive patterns
Strategy: try-catch
Validate before calling
// before rotating
test -f "$IPFS_PATH/config" || { echo "no repo at $IPFS_PATH"; exit 1; }
pgrep -f 'ipfs daemon' && { echo 'stop daemon first'; exit 1; } Try / catch
if err := doRotate(out, repoRoot, oldKey, alg, bits, given); err != nil {
if strings.Contains(err.Error(), "opening repo") {
// check daemon lock, IPFS_PATH, repo version
var inner = errors.Unwrap(err)
log.Printf("fsrepo open failed: %v", inner)
}
} Prevention
- Always stop the daemon before key rotate
- Pin IPFS_PATH explicitly in scripts
- Keep repo and binary versions in sync; run migrations promptly
When it happens
Trigger: Running `ipfs key rotate` while the daemon is running (repo lock held); IPFS_PATH points to a directory that was never initialized; repo needs a migration (version downgrade/upgrade); corrupted repo lock file.
Common situations: Forgetting to `ipfs daemon stop` before rotating; wrong IPFS_PATH environment variable; rotating after an upgrade that left the repo at a newer version than the binary supports.
Related errors
- opening repo (is the daemon running?): %w
- failed to open repo: %w
- failed to get config value: %q
- reading config from repo (%v)
- supernode routing was never fully implemented and has been r
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e00479ccbd66cbee.
Report an issue: GitHub.