ipfs/kubo · error
%s: MFS destination parent %q %q does not exist: %w
Error message
%s: MFS destination parent %q %q does not exist: %w
What it means
Before linking the added node into MFS, the command verifies the parent directory of the --to-files destination exists via mfs.Lookup; if it does not, this error wraps the lookup failure. MFS does not auto-create intermediate directories on PutNode, so a missing parent is fatal.
Source
Thrown at core/commands/add.go:615
}
// confirm dst is a dir
if mfsNode.Type() != mfs.TDir {
errCh <- fmt.Errorf("%s: MFS destination %q is not a directory", toFilesOptionName, toFilesDst)
return
}
// if MFS destination is a dir, append filename to the dir path
toFilesDst += gopath.Base(addit.Name())
}
// error if we try to overwrite a preexisting file destination
if fileAddedToMFS && !dstAsDir {
errCh <- fmt.Errorf("%s: MFS destination is a file: only one entry can be copied to %q", toFilesOptionName, toFilesDst)
return
}
_, err = mfs.Lookup(ipfsNode.FilesRoot, gopath.Dir(toFilesDst))
if err != nil {
errCh <- fmt.Errorf("%s: MFS destination parent %q %q does not exist: %w", toFilesOptionName, toFilesDst, gopath.Dir(toFilesDst), err)
return
}
var nodeAdded ipld.Node
nodeAdded, err = api.Dag().Get(req.Context, pathAdded.RootCid())
if err != nil {
errCh <- err
return
}
err = mfs.PutNode(ipfsNode.FilesRoot, toFilesDst, nodeAdded)
if err != nil {
errCh <- fmt.Errorf("%s: cannot put node in path %q: %w", toFilesOptionName, toFilesDst, err)
return
}
fileAddedToMFS = true
}
errCh <- err
}()View on GitHub (pinned to 329838acdf)
Solutions
- Create the parent directory first: ipfs files mkdir -p /a/b
- Use an existing MFS directory as the destination (trailing slash form)
- Correct the typo in the --to-files path
Example fix
// before ipfs add --to-files /a/b/c.txt file # /a/b missing // after ipfs files mkdir -p /a/b ipfs add --to-files /a/b/c.txt file
Defensive patterns
Strategy: validation
Validate before calling
// create parent dirs before add --to-files parent=$(dirname "$DST") ipfs files mkdir -p "$parent" ipfs add --to-files "$DST" "$FILE"
Prevention
- Always `ipfs files mkdir -p` the parent of the --to-files path
- Do not assume --to-files creates intermediate directories
- Verify destination parents exist with `ipfs files ls` in setup scripts
When it happens
Trigger: Run `ipfs add --to-files /a/b/c.txt file` where /a/b does not exist in MFS: mfs.Lookup(FilesRoot, '/a/b') fails, producing '--to-files: MFS destination parent "/a/b/c.txt" "/a/b" does not exist: <lookup error>'.
Common situations: Fresh node with empty MFS (no /tmp or /docs created yet); typo in destination path; scripts assuming --to-files creates nested paths implicitly like mkdir -p.
Related errors
- %s: cannot add unnamed files to MFS
- %s: %w
- %s: MFS destination directory %q does not exist: %w
- %s: MFS destination %q is not a directory
- %s: MFS destination is a file: only one entry can be copied
AI-assisted analysis of ipfs/kubo@329838acdf (2026-09-03).
Data as JSON: /api/errors/93dd4e0569e32d24.
Report an issue: GitHub.