{"record":{"id":"93dd4e0569e32d24","repo":"ipfs/kubo","slug":"s-mfs-destination-parent-q-q-does-not-exist","errorCode":null,"errorMessage":"%s: MFS destination parent %q %q does not exist: %w","messagePattern":"(.+?): MFS destination parent %q %q does not exist: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/add.go","lineNumber":615,"sourceCode":"\t\t\t\t\t\t}\n\t\t\t\t\t\t// confirm dst is a dir\n\t\t\t\t\t\tif mfsNode.Type() != mfs.TDir {\n\t\t\t\t\t\t\terrCh <- fmt.Errorf(\"%s: MFS destination %q is not a directory\", toFilesOptionName, toFilesDst)\n\t\t\t\t\t\t\treturn\n\t\t\t\t\t\t}\n\t\t\t\t\t\t// if MFS destination is a dir, append filename to the dir path\n\t\t\t\t\t\ttoFilesDst += gopath.Base(addit.Name())\n\t\t\t\t\t}\n\n\t\t\t\t\t// error if we try to overwrite a preexisting file destination\n\t\t\t\t\tif fileAddedToMFS && !dstAsDir {\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"%s: MFS destination is a file: only one entry can be copied to %q\", toFilesOptionName, toFilesDst)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\t_, err = mfs.Lookup(ipfsNode.FilesRoot, gopath.Dir(toFilesDst))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"%s: MFS destination parent %q %q does not exist: %w\", toFilesOptionName, toFilesDst, gopath.Dir(toFilesDst), err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\n\t\t\t\t\tvar nodeAdded ipld.Node\n\t\t\t\t\tnodeAdded, err = api.Dag().Get(req.Context, pathAdded.RootCid())\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terrCh <- err\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\terr = mfs.PutNode(ipfsNode.FilesRoot, toFilesDst, nodeAdded)\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\terrCh <- fmt.Errorf(\"%s: cannot put node in path %q: %w\", toFilesOptionName, toFilesDst, err)\n\t\t\t\t\t\treturn\n\t\t\t\t\t}\n\t\t\t\t\tfileAddedToMFS = true\n\t\t\t\t}\n\t\t\t\terrCh <- err\n\t\t\t}()","sourceCodeStart":597,"sourceCodeEnd":633,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/add.go#L597-L633","documentation":"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.","triggerScenarios":"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>'.","commonSituations":"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.","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"],"exampleFix":"// before\nipfs add --to-files /a/b/c.txt file   # /a/b missing\n// after\nipfs files mkdir -p /a/b\nipfs add --to-files /a/b/c.txt file","handlingStrategy":"validation","validationCode":"// create parent dirs before add --to-files\nparent=$(dirname \"$DST\")\nipfs files mkdir -p \"$parent\"\nipfs add --to-files \"$DST\" \"$FILE\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["cli","mfs","to-files","path-not-found"],"backgroundTag":"mfs-parent-directory-missing","analyzedSha":"329838acdfafae224582930457efe80aa217afc0","analyzedAt":"2026-09-03T18:30:52.135Z","contentChangedAt":"2026-09-03T18:30:52.135Z","schemaVersion":2},"datasetVersion":"2026-09-11T00:17:11.886Z"}