hyperledger/fabric · error
chaincode install package must be provided
Error message
chaincode install package must be provided
What it means
CalculatePackageIDInput.Validate enforces that a packaged chaincode tarball (--package-file) was supplied before the calculatepackageid command does any work. The command computes a package ID from an install package file, so without the file path there is nothing to hash. This is a pure input-validation error raised before any file I/O.
Source
Thrown at internal/peer/lifecycle/chaincode/calculatepackageid.go:45
Writer io.Writer
}
// CalculatePackageIDInput holds the input parameters for calculating
// the package ID of a packaged chaincode
type CalculatePackageIDInput struct {
PackageFile string
OutputFormat string
}
// CalculatePackageIDOutput holds the JSON output format
type CalculatePackageIDOutput struct {
PackageID string `json:"package_id"`
}
// Validate checks that the required parameters are provided
func (i *CalculatePackageIDInput) Validate() error {
if i.PackageFile == "" {
return errors.New("chaincode install package must be provided")
}
return nil
}
// CalculatePackageIDCmd returns the cobra command for calculating
// the package ID for a packaged chaincode
func CalculatePackageIDCmd(p *PackageIDCalculator) *cobra.Command {
calculatePackageIDCmd := &cobra.Command{
Use: "calculatepackageid [packageFile]",
Short: "Calculate the package ID for a chaincode.",
Long: "Calculate the package ID for a packaged chaincode.",
ValidArgs: []string{"1"},
RunE: func(cmd *cobra.Command, args []string) error {
if p == nil {
p = &PackageIDCalculator{
Reader: &persistence.FilesystemIO{},
Writer: os.Stdout,View on GitHub (pinned to 2736b63f8f)
Solutions
- Add --package-file pointing to the packaged chaincode tarball produced by `peer lifecycle chaincode package`, e.g. mycc_1.0.tgz.
- In Go, set CalculatePackageIDInput.PackageFile to the full path of the .tgz before calling Validate().
- Confirm the packaging step succeeded and the file exists at the given path before invoking calculatepackageid.
Example fix
// before peer lifecycle chaincode calculatepackageid // after peer lifecycle chaincode calculatepackageid --package-file ./mycc_1.0.tgz
Defensive patterns
Strategy: validation
Validate before calling
info := chaincode.CalculatePackageIDInput{}
if info.PackageFile == "" {
return errors.New("pass --package-file pointing to the packaged .tgz")
}
if _, err := os.Stat(info.PackageFile); err != nil {
return fmt.Errorf("package file missing: %w", err)
} Try / catch
if err := info.Validate(); err != nil {
if strings.Contains(err.Error(), "must be provided") {
return flag.ErrHelp // print usage so the operator sees the required flag
}
return err
} Prevention
- Always run `peer lifecycle chaincode package` first and capture the .tgz path.
- Use absolute paths for --package-file in scripts.
- Check file existence before invoking the command in CI pipelines.
When it happens
Trigger: Running `peer lifecycle chaincode calculatepackageid` without the --package-file flag, or programmatically constructing CalculatePackageIDInput with PackageFile left as empty string and calling Validate().
Common situations: Copy-pasting a command example and dropping the --package-file flag; scripting where the packaged .tgz path variable is empty because a prior `package` step failed or the variable wasn't exported.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- fetch target required, oldest, newest, config, or a number
- filename cannot be empty
- The required parameter 'channelID' is empty. Rerun the comma
- The required parameter 'package-id' is empty. Rerun the comm
- chaincode install package must be provided
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/3bb7d36c72bb29b5.
Report an issue: GitHub.