{"record":{"id":"fcc4d0e9f69b388a","repo":"ipfs/kubo","slug":"cannot-delete-root","errorCode":null,"errorMessage":"cannot delete root","messagePattern":"cannot delete root","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1433,"sourceCode":"\t\t\t\terrs = append(errs, fmt.Errorf(\"%s: %w\", path, err))\n\t\t\t}\n\t\t}\n\t\tif len(errs) > 0 {\n\t\t\tfor _, err = range errs {\n\t\t\t\te := res.Emit(err.Error())\n\t\t\t\tif e != nil {\n\t\t\t\t\treturn e\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn fmt.Errorf(\"can't remove some files\")\n\t\t}\n\t\treturn nil\n\t},\n}\n\nfunc removePath(filesRoot *mfs.Root, path string, force bool, dashr bool) error {\n\tif path == \"/\" {\n\t\treturn fmt.Errorf(\"cannot delete root\")\n\t}\n\n\t// 'rm a/b/c/' will fail unless we trim the slash at the end\n\tif path[len(path)-1] == '/' {\n\t\tpath = path[:len(path)-1]\n\t}\n\n\tdir, name := gopath.Split(path)\n\n\tpdir, err := getParentDir(filesRoot, dir)\n\tif err != nil {\n\t\tif force && err == os.ErrNotExist {\n\t\t\treturn nil\n\t\t}\n\t\treturn err\n\t}\n\n\tif force {","sourceCodeStart":1415,"sourceCodeEnd":1451,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1415-L1451","documentation":"First guard in removePath (called by `ipfs files rm`): it refuses to remove the MFS root '/'. Deleting the root would leave the node's files layer without a valid root, so the path argument is rejected before any lookup. Generic sentinel-style validation of the target path.","triggerScenarios":"Thrown at core/commands/files.go:1433 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove the contents instead of the root: `ipfs files rm -r /<child>` for each child.","To reset MFS entirely, reinitialize or replace the root via the node-level root APIs rather than `files rm /`."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}