{"record":{"id":"fde79ec175eec4ec","repo":"ipfs/kubo","slug":"cannot-change-cid-format-of-the-mfs-root-use-ipf","errorCode":null,"errorMessage":"cannot change CID format of the MFS root; use 'ipfs config Import.CidVersion' and 'ipfs config Import.HashFunction' instead","messagePattern":"cannot change CID format of the MFS root; use 'ipfs config Import\\.CidVersion' and 'ipfs config Import\\.HashFunction' instead","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/files.go","lineNumber":1317,"sourceCode":"`,\n\t},\n\tArguments: []cmds.Argument{\n\t\tcmds.StringArg(\"path\", true, false, \"Path to change (must not be '/').\"),\n\t},\n\tOptions: []cmds.Option{\n\t\tcidVersionOption,\n\t\thashOption,\n\t},\n\tRun: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {\n\t\tnd, err := cmdenv.GetNode(env)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tdefer mfsPinLock(nd, req.Context).Unlock(req.Context)\n\n\t\tpath := req.Arguments[0]\n\t\tif path == \"/\" {\n\t\t\treturn fmt.Errorf(\"cannot change CID format of the MFS root; \" +\n\t\t\t\t\"use 'ipfs config Import.CidVersion' and 'ipfs config Import.HashFunction' instead\")\n\t\t}\n\n\t\tflush, _ := req.Options[filesFlushOptionName].(bool)\n\n\t\t// Note: files chcid is for explicitly changing CID format, so we don't\n\t\t// fall back to Import config here. If no options are provided, it does nothing.\n\t\tprefix, err := getPrefix(req, nil)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := updatePath(nd.FilesRoot, path, prefix); err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif flush {\n\t\t\tif _, err = mfs.FlushPath(req.Context, nd.FilesRoot, path); err != nil {\n\t\t\t\treturn err","sourceCodeStart":1299,"sourceCodeEnd":1335,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/files.go#L1299-L1335","documentation":"The `ipfs files chcid` command refuses to run when the target path is the MFS root '/'. The root's CID format cannot be changed in place via chcid; instead the caller must change the node-level import settings (Import.CidVersion / Import.HashFunction) or replace the root with `ipfs files chmod`-style root replacement. It is a precondition check on the path argument.","triggerScenarios":"Thrown at core/commands/files.go:1317 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Target a subdirectory instead of '/', e.g. `ipfs files chcid /mydir --cid-version 1`.","To change the root's CID format, set `ipfs config Import.CidVersion` / `Import.HashFunction` and rebuild MFS, or copy contents into a new directory and replace the root."],"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"}