{"record":{"id":"bc744c89266530a0","repo":"ipfs/kubo","slug":"s-option-requires-s-to-be-set","errorCode":null,"errorMessage":"%s option requires %s to be set","messagePattern":"(.+?) option requires (.+?) to be set","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/commands/add.go","lineNumber":445,"sourceCode":"\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\n\t\ttoadd := req.Files\n\t\tif wrap {\n\t\t\ttoadd = files.NewSliceDirectory([]files.DirEntry{","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/ipfs/kubo/blob/329838acdfafae224582930457efe80aa217afc0/core/commands/add.go#L427-L463","documentation":"`--pin-name` names the pin created by `ipfs add`, so it is meaningless without pinning. When `--pin=false` is in effect while `--pin-name` is set, kubo rejects the command because there is no pin to attach the name to.","triggerScenarios":"`ipfs add --pin=false --pin-name=backup file`; RPC add with Pin=false and PinName set; templates that always emit --pin-name while another flag disables pinning.","commonSituations":"Scripts parameterizing pin on/off but always passing a pin name; users disabling pinning to avoid pinset entries yet still naming the (nonexistent) pin.","solutions":["Enable pinning: remove --pin=false or pass --pin=true","Remove --pin-name if the add should not be pinned","Pin by CID later: `ipfs pin add --name=... <cid>` after a non-pinned add"],"exampleFix":"// before\nipfs add --pin=false --pin-name=release ./dist\n// after\nipfs add --pin=true --pin-name=release ./dist","handlingStrategy":"validation","validationCode":"if pinName != \"\" && !pin {\n  return errors.New(\"--pin-name requires --pin to be enabled\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Only emit --pin-name when pinning is on","Default to pin=true unless the caller explicitly opts out"],"tags":["cli","validation","pinning"],"backgroundTag":"option-requires-companion-option","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"}