{"record":{"id":"b6d3333a96ac4d44","repo":"ipfs/kubo","slug":"cp-cannot-put-node-in-path-s-s","errorCode":null,"errorMessage":"cp: cannot put node in path %s: %s","messagePattern":"cp: cannot put node in path (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":597,"sourceCode":"\t\t\t}\n\t\t}\n\n\t\tforce, _ := req.Options[forceOptionName].(bool)\n\t\tif force {\n\t\t\tif err = unlinkNodeIfExists(nd, dst); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot unlink existing file: %s\", err)\n\t\t\t}\n\t\t}\n\n\t\tflush, _ := req.Options[filesFlushOptionName].(bool)\n\n\t\tif err := updateNoFlushCounter(nd, flush); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\terr = mfs.PutNode(nd.FilesRoot, dst, node)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"cp: cannot put node in path %s: %s\", dst, err)\n\t\t}\n\t\tif flush {\n\t\t\tif _, err := mfs.FlushPath(req.Context, nd.FilesRoot, dst); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot flush the created file %s: %s\", dst, err)\n\t\t\t}\n\t\t\t// Flush parent to clear directory cache and free memory.\n\t\t\tparent := gopath.Dir(dst)\n\t\t\tif _, err = mfs.FlushPath(req.Context, nd.FilesRoot, parent); err != nil {\n\t\t\t\treturn fmt.Errorf(\"cp: cannot flush the created file's parent folder %s: %s\", dst, err)\n\t\t\t}\n\t\t}\n\n\t\treturn nil\n\t},\n}\n\nfunc getNodeFromPath(ctx context.Context, node *core.IpfsNode, api iface.CoreAPI, p string) (ipld.Node, error) {\n\t// A content path or native IPFS URI (/ipfs/cid, ipfs://cid, /ipns/name, ...)","sourceCodeStart":579,"sourceCodeEnd":615,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L579-L615","documentation":"After resolving and validating the source, `ipfs files cp` calls mfs.PutNode to place the node at dst; this error wraps that failure. Typical causes are missing parent directories in dst, dst already existing (without --force), or invalid dst path syntax.","triggerScenarios":"Running `ipfs files cp <src> <dst>` where dst's parent doesn't exist in MFS, dst already exists and no --force was given, dst is malformed, or the MFS write fails (e.g. root not writable, path resolves through a non-directory).","commonSituations":"Forgetting to `ipfs files mkdir -p` the destination folder; copying without --force over an existing entry; using a trailing-slash dst where base-name derivation fails.","solutions":["Create parent directories first: `ipfs files mkdir -p <parent-of-dst>`","If dst exists, remove it (`ipfs files rm -r <dst>`) or re-run with `--force`","Validate dst syntax: use `files rm` naming conventions, and avoid trailing slashes unless intending base-name derivation","Check `ipfs files stat /` to confirm MFS root is healthy"],"exampleFix":"// before\nipfs files cp /ipfs/Qm... /nonexistent/dir/file\n// error: cp: cannot put node in path /nonexistent/dir/file: ...\n\n// after\nipfs files mkdir -p /nonexistent/dir\nipfs files cp /ipfs/Qm... /nonexistent/dir/file","handlingStrategy":"validation","validationCode":"// create parents and clear collisions before cp\nrun(\"ipfs\", \"files\", \"mkdir\", \"-p\", filepath.Dir(dst))\nif _, err := run(\"ipfs\", \"files\", \"stat\", dst); err == nil {\n    run(\"ipfs\", \"files\", \"rm\", \"-r\", dst) // or use --force\n}","typeGuard":null,"tryCatchPattern":"if err := ipfsFilesCp(src, dst); err != nil {\n    if strings.Contains(err.Error(), \"cannot put node in path\") {\n        // mkdir -p parents, remove existing dst, retry\n    }\n}","preventionTips":["Always `ipfs files mkdir -p` the destination parent first","Decide explicitly between --force and pre-removal of dst","Avoid trailing slashes in dst unless base-name derivation is intended"],"tags":["mfs","cli","cp"],"backgroundTag":"mfs-write-failed","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"}