hyperledger/fabric · error

Must supply genesis block file

Error message

Must supply genesis block file

What it means

getJoinCCSpec requires the genesis block file path (--blockpath/-b) to be set; when it is the undefined empty value it returns this error before reading the file. The genesis block is needed to build the CSCC join proposal payload. Note this is distinct from the sibling check in join() that reports 'Must supply genesis block path'.

Source

Thrown at internal/peer/channel/join.go:60

}

// GBFileNotFoundErr genesis block file not found
type GBFileNotFoundErr string

func (e GBFileNotFoundErr) Error() string {
	return fmt.Sprintf("genesis block file not found %s", string(e))
}

// ProposalFailedErr proposal failed
type ProposalFailedErr string

func (e ProposalFailedErr) Error() string {
	return fmt.Sprintf("proposal failed (err: %s)", string(e))
}

func getJoinCCSpec() (*pb.ChaincodeSpec, error) {
	if genesisBlockPath == common.UndefinedParamValue {
		return nil, errors.New("Must supply genesis block file")
	}

	gb, err := os.ReadFile(genesisBlockPath)
	if err != nil {
		return nil, GBFileNotFoundErr(err.Error())
	}
	// Build the spec
	input := &pb.ChaincodeInput{Args: [][]byte{[]byte(cscc.JoinChain), gb}}

	spec := &pb.ChaincodeSpec{
		Type:        pb.ChaincodeSpec_Type(pb.ChaincodeSpec_Type_value["GOLANG"]),
		ChaincodeId: &pb.ChaincodeID{Name: "cscc"},
		Input:       input,
	}

	return spec, nil
}

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Rerun `peer channel join -b ./channel-artifacts/mychannel.block` with a valid genesis block path.
  2. Generate the genesis block if missing: `configtxgen -profile ... -outputBlock mychannel.block -channelID mychannel`.
  3. Verify the file exists and is readable by the CLI user before joining.

Example fix

// before
peer channel join
// after
peer channel join -b ./channel-artifacts/mychannel.block
Defensive patterns

Strategy: validation

Validate before calling

// bash
: "${GENESIS_BLOCK:?set -b / GENESIS_BLOCK before running}"
[ -r "$GENESIS_BLOCK" ] || { echo "genesis block missing: $GENESIS_BLOCK"; exit 1; }
peer channel join -b "$GENESIS_BLOCK"

Prevention

When it happens

Trigger: Calling the internal getJoinCCSpec (via `peer channel join`) without providing --blockpath pointing to the channel genesis block file.

Common situations: Forgetting -b when joining a channel; pointing at a config-block file instead of the genesis block in scripts generated for a different flow; generating artifacts where mychannel.block was never created.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/75633f14809b7e3c. Report an issue: GitHub.