ipfs/kubo · error
some blocks not removed
Error message
some blocks not removed
What it means
`ipfs block rm` reports this aggregate error when at least one requested block could not be removed. During iteration each per-block failure prints `cannot remove <hash>: <error>` to stderr, sets someFailed=true, and at the end the command returns `some blocks not removed` so scripts see a non-zero exit even though other blocks were removed successfully.
Source
Thrown at core/commands/block.go:357
for {
res, err := res.Next()
if err == io.EOF {
break
} else if err != nil {
return err
}
r := res.(*removedBlock)
if r.Hash == "" && r.Error != "" {
return fmt.Errorf("aborted: %s", r.Error)
} else if r.Error != "" {
someFailed = true
fmt.Fprintf(os.Stderr, "cannot remove %s: %s\n", r.Hash, r.Error)
} else {
fmt.Fprintf(os.Stdout, "removed %s\n", r.Hash)
}
}
if someFailed {
return fmt.Errorf("some blocks not removed")
}
return nil
},
},
Type: removedBlock{},
}
View on GitHub (pinned to 329838acdf)
Solutions
- Check stderr for the per-block `cannot remove <hash>: <reason>` lines
- Unpin blocks first with `ipfs pin rm <cid>` before removing them
- Use --force to ignore errors for blocks that don't exist
- Re-run with only the CIDs that failed after addressing each specific cause
Example fix
// before ipfs block rm QmPinned QmOk // after ipfs pin rm QmPinned ipfs block rm QmPinned QmOk
Defensive patterns
Strategy: validation
Validate before calling
// pre-check pins before removal
for _, cid := range cids {
if err := exec.Command("ipfs", "pin", "ls", cid).Run(); err == nil {
_ = exec.Command("ipfs", "pin", "rm", cid).Run()
}
} Type guard
null
Try / catch
if err != nil && err.Error() == "some blocks not removed" {
// parse stderr lines `cannot remove <hash>: <reason>` and retry survivors
} Prevention
- Unpin blocks before removing them
- Use --force for CIDs that may not exist
- Parse per-block stderr lines to know which failed
- Keep a per-CID error log for batch removals
When it happens
Trigger: `ipfs block rm <cids...>` where any CID fails removal (e.g. it is pinned, or does not exist without --force, or the datastore errors).
Common situations: Attempting to remove pinned blocks (block rm does not unpin), removing nonexistent CIDs, or batch scripts that mix valid and invalid CIDs.
Related errors
- %s option requires %s to be set
- aborted: %s
- --%s implies --%s=false and cannot be combined with --%s=tru
- checking if new root exists: %w
- new root %s does not exist locally; fetch it first with 'ipf
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/95deff6f81eefe06.
Report an issue: GitHub.