{"record":{"id":"86cc794cb29680bd","repo":"ipfs/kubo","slug":"s-and-s-options-are-not-compatible","errorCode":null,"errorMessage":"%s and %s options are not compatible","messagePattern":"(.+?) and (.+?) options are not compatible","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/add.go","lineNumber":442,"sourceCode":"\t\t\tfastProvideRoot = false\n\t\t\tfastProvideDAG = false\n\t\t}\n\n\t\t// Storing optional mode or mtime (UnixFS 1.5) requires root block\n\t\t// to always be 'dag-pb' and not 'raw'. Below adjusts raw-leaves setting, if possible.\n\t\tif preserveMode || preserveMtime || mode != 0 || mtime != 0 {\n\t\t\t// Error if --raw-leaves flag was explicitly passed by the user.\n\t\t\t// (let user make a decision to manually disable it and retry)\n\t\t\tif rbset && rawblks {\n\t\t\t\treturn fmt.Errorf(\"%s can't be used with UnixFS metadata like mode or modification time\", rawLeavesOptionName)\n\t\t\t}\n\t\t\t// No explicit preference from user, disable raw-leaves and continue\n\t\t\trbset = true\n\t\t\trawblks = false\n\t\t}\n\n\t\tif onlyHash && toFilesSet {\n\t\t\treturn fmt.Errorf(\"%s and %s options are not compatible\", onlyHashOptionName, toFilesOptionName)\n\t\t}\n\t\tif !dopin && pinNameSet {\n\t\t\treturn fmt.Errorf(\"%s option requires %s to be set\", pinNameOptionName, pinOptionName)\n\t\t}\n\t\tif wrap && toFilesSet {\n\t\t\treturn fmt.Errorf(\"%s and %s options are not compatible\", wrapOptionName, toFilesOptionName)\n\t\t}\n\n\t\thashFunCode, ok := mh.Names[strings.ToLower(hashFunStr)]\n\t\tif !ok {\n\t\t\treturn fmt.Errorf(\"unrecognized hash function: %q\", strings.ToLower(hashFunStr))\n\t\t}\n\n\t\tenc, err := cmdenv.GetCidEncoder(req)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n","sourceCodeStart":424,"sourceCodeEnd":460,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/add.go#L424-L460","documentation":"`--only-hash` computes the CID without storing any blocks, while `--to-files` links the added content into MFS, which requires stored blocks. The two are contradictory, so kubo rejects the invocation up front.","triggerScenarios":"`ipfs add --only-hash --to-files=/foo file`; RPC add with HashOnly=true and ToFiles set; wrapper scripts that append --to-files to a shared command line also using --only-hash.","commonSituations":"Dry-run CID computation in a wrapper that unconditionally passes --to-files; users expecting --only-hash to populate MFS.","solutions":["Remove --only-hash if the file should land in MFS","Remove --to-files if only the CID is needed","Split into two calls: --only-hash for the CID, then a real add with --to-files"],"exampleFix":"// before\nipfs add --only-hash --to-files=/big-file big.bin\n// after\nipfs add --to-files=/big-file big.bin","handlingStrategy":"validation","validationCode":"if onlyHash && toFiles != \"\" {\n  return errors.New(\"--only-hash is incompatible with --to-files\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep dry-run (--only-hash) and MFS-write (--to-files) invocations as separate code paths","Grep wrapper scripts for flag collisions before composing add commands"],"tags":["cli","validation","mfs","only-hash"],"backgroundTag":"incompatible-option-combination","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"}