ipfs/kubo · error
checking if new root exists: %w
Error message
checking if new root exists: %w
What it means
After opening the local repo, `ipfs files chroot` checks that the proposed new root block exists in the local blockstore (bs.Has). The generic blockstore error is wrapped with this message; separately, if the block is absent and the CID is not the well-known empty-directory CID, the command returns 'new root %s does not exist locally; fetch it first with ipfs block get'.
Source
Thrown at core/commands/files.go:1770
// Get config root to open repo directly
cctx := env.(*oldcmds.Context)
cfgRoot := cctx.ConfigRoot
// Open repo directly (daemon must not be running)
repo, err := fsrepo.Open(cfgRoot)
if err != nil {
return fmt.Errorf("opening repo (is the daemon running?): %w", err)
}
defer repo.Close()
localDS := repo.Datastore()
bs := bstore.NewBlockstore(localDS)
// Check new root exists locally and is a directory
hasBlock, err := bs.Has(req.Context, newRootCid)
if err != nil {
return fmt.Errorf("checking if new root exists: %w", err)
}
if !hasBlock {
// Special case: empty dir is always available (hardcoded in boxo)
emptyDirCid := ft.EmptyDirNode().Cid()
if !newRootCid.Equals(emptyDirCid) {
return fmt.Errorf("new root %s does not exist locally; fetch it first with 'ipfs block get'", enc.Encode(newRootCid))
}
}
// Validate it's a directory (not a file)
if hasBlock {
blk, err := bs.Get(req.Context, newRootCid)
if err != nil {
return fmt.Errorf("reading new root block: %w", err)
}
pbNode, err := dag.DecodeProtobuf(blk.RawData())
if err != nil {
return fmt.Errorf("new root is not a valid dag-pb node: %w", err)View on GitHub (pinned to 329838acdf)
Solutions
- Fetch the block first: `ipfs block get <cid>` (with the daemon running) so it lands in the local blockstore, then re-run chroot.
- Verify the CID exists on the network at all; a wrong CID will never be fetchable.
- If it is a datastore error, check disk space/integrity and inspect daemon logs for datastore errors.
Example fix
# before ipfs files chroot --confirm bafybei... # does not exist locally # after ipfs block get bafybei... > /dev/null ipfs files chroot --confirm bafybei...
Defensive patterns
Strategy: validation
When it happens
Trigger: Chrooting to a CID whose block was never fetched locally (no `ipfs block get`/garbage-collected away); a datastore error (I/O failure, corruption) surfacing from bs.Has(req.Context, newRootCid).
Common situations: Referencing a CID seen on the network but never pinned or fetched; a GC run that removed the block; datastore backend failures (disk full, bad flatfs/badger state).
Related errors
- new root %s does not exist locally; fetch it first with 'ipf
- inline-limit %d exceeds maximum allowed size of %d bytes
- aborted: %s
- some blocks not removed
- invalid format string: %q
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/36eb231c774408cf.
Report an issue: GitHub.