ipfs/kubo · error
cp: cannot flush the created file
Error message
cp: cannot flush the created file %s: %s
What it means
After successfully placing the node, `ipfs files cp --flush` (flush is enabled by default) flushes the created file via mfs.FlushPath; this error wraps a failure flushing dst itself. The node was placed but its data could not be committed from the in-memory MFS to the DAG service/datastore.
Solutions
- Check disk space and datastore health (`ipfs repo stat`, daemon logs)
- Re-run the copy; if dst was concurrently removed, serialize concurrent MFS writers
- Run `ipfs files flush /` to reconcile MFS state, then retry
- Investigate datastore errors in daemon logs (`GOLOG_LOG_LEVEL=debug ipfs daemon`)
Example fix
null
Defensive patterns
Strategy: retry
Validate before calling
// check repo headroom before large copies
run("ipfs", "repo", "stat") // verify free space / quota Try / catch
err := ipfsFilesCp(src, dst)
if err != nil && strings.Contains(err.Error(), "cannot flush the created file") {
time.Sleep(backoff)
run("ipfs", "files", "flush", "/")
err = ipfsFilesCp(src, dst)
} Prevention
- Monitor disk space for the repo datastore
- Serialize MFS writes; avoid concurrent writers to the same path
- Run `ipfs files flush /` after bulk operations and check daemon logs
When it happens
Trigger: Running `ipfs files cp` with flush enabled where mfs.FlushPath on dst fails — e.g. underlying blockservice/datastore write errors, disk full, or the just-placed path was concurrently removed by another operation.
Common situations: Full disk or datastore quota during a large copy; concurrent MFS operations from another CLI/API client removing dst between put and flush; datastore (e.g. badger) corruption.
Related errors
- cp: cannot flush the created file's parent folder
- cp: cannot get node from path
- cp: cannot put node in path
- cp: cannot unlink existing file
- cp: source must be a valid UnixFS (dag-pb or raw codec)
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/e05981d0f69e368c.
Report an issue: GitHub.
Appendix: source
Thrown at core/commands/files.go:601
if force {
if err = unlinkNodeIfExists(nd, dst); err != nil {
return fmt.Errorf("cp: cannot unlink existing file: %s", err)
}
}
flush, _ := req.Options[filesFlushOptionName].(bool)
if err := updateNoFlushCounter(nd, flush); err != nil {
return err
}
err = mfs.PutNode(nd.FilesRoot, dst, node)
if err != nil {
return fmt.Errorf("cp: cannot put node in path %s: %s", dst, err)
}
if flush {
if _, err := mfs.FlushPath(req.Context, nd.FilesRoot, dst); err != nil {
return fmt.Errorf("cp: cannot flush the created file %s: %s", dst, err)
}
// Flush parent to clear directory cache and free memory.
parent := gopath.Dir(dst)
if _, err = mfs.FlushPath(req.Context, nd.FilesRoot, parent); err != nil {
return fmt.Errorf("cp: cannot flush the created file's parent folder %s: %s", dst, err)
}
}
return nil
},
}
func getNodeFromPath(ctx context.Context, node *core.IpfsNode, api iface.CoreAPI, p string) (ipld.Node, error) {
// A content path or native IPFS URI (/ipfs/cid, ipfs://cid, /ipns/name, ...)
// is resolved through the DAG. Anything else is treated as an MFS path.
if pth, err := path.NewPathFromURI(p); err == nil {
return api.ResolveNode(ctx, pth)
}View on GitHub (pinned to 329838acdf)