{"record":{"id":"abadbdcdadfdae04","repo":"hyperledger/fabric","slug":"chaincode-path-must-be-specified","errorCode":null,"errorMessage":"chaincode path must be specified","messagePattern":"chaincode path must be specified","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/lifecycle/chaincode/package.go","lineNumber":51,"sourceCode":"\tCommand          *cobra.Command\n\tInput            *PackageInput\n\tPlatformRegistry PlatformRegistry\n\tWriter           Writer\n}\n\n// PackageInput holds the input parameters for packaging a\n// ChaincodeInstallPackage\ntype PackageInput struct {\n\tOutputFile string\n\tPath       string\n\tType       string\n\tLabel      string\n}\n\n// Validate checks for the required inputs\nfunc (p *PackageInput) Validate() error {\n\tif p.Path == \"\" {\n\t\treturn errors.New(\"chaincode path must be specified\")\n\t}\n\tif p.Type == \"\" {\n\t\treturn errors.New(\"chaincode language must be specified\")\n\t}\n\tif p.OutputFile == \"\" {\n\t\treturn errors.New(\"output file must be specified\")\n\t}\n\tif p.Label == \"\" {\n\t\treturn errors.New(\"package label must be specified\")\n\t}\n\tif err := persistence.ValidateLabel(p.Label); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\n// PackageCmd returns the cobra command for packaging chaincode","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/lifecycle/chaincode/package.go#L33-L69","documentation":"PackageInput.Validate returns this when the --path flag is empty when packaging a chaincode. The path tells the platform registry where to find the chaincode source that gets embedded in the package's code.tar.gz. Without it no deployment payload can be built, so the packaging command refuses to proceed.","triggerScenarios":"Running `peer lifecycle chaincode package` without the --path flag, or passing --path \"\" (e.g. a shell variable that is empty because the env var it referenced was unset).","commonSituations":"Scripted CI pipelines where CC_SRC_PATH is not exported; copy-pasted commands where the path flag was dropped; packaging a Go chaincode from the wrong working directory and assuming path is optional.","solutions":["Re-run the command with the flag: peer lifecycle chaincode package cc.tar.gz --path <path-to-chaincode-source> --lang <lang> --label <label>.","If using variables, verify CC_SRC_PATH is non-empty before invoking the CLI (echo it or add a shell check).","Remember path must point to the chaincode source relative/absolute on the machine running the command, not inside the container."],"exampleFix":"// before (empty input)\np := &PackageInput{Type: \"go\", Label: \"cc_1\"}\nerr := p.Validate() // \"chaincode path must be specified\"\n// after\np := &PackageInput{Path: \"../chaincode/fabric-samples/asset-transfer-basic/chaincode-go\", Type: \"go\", Label: \"basic_1.0\"}\nif p.Path == \"\" {\n    return errors.New(\"chaincode path must be specified\")\n}\nerr := p.Validate()","handlingStrategy":"validation","validationCode":"#!/bin/bash\n: \"${CC_SRC_PATH:?Set CC_SRC_PATH to the chaincode source path}\"\n[ -d \"$CC_SRC_PATH\" ] || { echo \"chaincode path does not exist: $CC_SRC_PATH\"; exit 1; }\npeer lifecycle chaincode package \"$OUT\" --path \"$CC_SRC_PATH\" --lang \"$CC_LANG\" --label \"$LABEL\"","typeGuard":null,"tryCatchPattern":"if ! out=$(peer lifecycle chaincode package \"$OUT\" --path \"$CC_SRC_PATH\" --lang \"$LANG_\" --label \"$LABEL\" 2>&1); then\n  case \"$out\" in\n    *\"chaincode path must be specified\"*) echo \"Add --path <chaincode source dir>\"; exit 2 ;;\n    *) echo \"$out\"; exit 1 ;;\n  esac\nfi","preventionTips":["Always pass --path explicitly; never rely on shell defaults.","Use ${VAR:?} guards for CC_SRC_PATH in scripts.","Test with `[ -d \"$CC_SRC_PATH\" ]` before packaging.","Keep a canonical package command in a shared script."],"tags":["hyperledger-fabric","cli","validation","missing-flag"],"backgroundTag":"missing-required-argument","analyzedSha":"2736b63f8fd5932511d56fe68b7039d15977f7f6","analyzedAt":"2026-09-04T08:52:36.465Z","contentChangedAt":"2026-09-04T08:52:36.465Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}