hyperledger/fabric · error

chaincode definition for '%s' exists, but chaincode is not i

Error message

chaincode definition for '%s' exists, but chaincode is not installed

What it means

CachedChaincodeInfo returns this when the chaincode has an approved/committed definition (chaincodeInfo.Approved true) but InstallInfo is nil and cei.UserRunsCC is false — meaning the chaincode package is not installed on this peer and the peer is not configured to run the chaincode externally (UserRunsCC, i.e. 'build external' mode). Endorsement cannot proceed without knowing the package.

Source

Thrown at core/chaincode/lifecycle/endorsement_info.go:99

		// TODO this is a transient error which indicates that this query executor is executing against a chaincode
		// whose definition has already changed (the cache may be ahead of the committed state, but never behind).  In this
		// case, we should simply abort the tx, and re-acquire a query executor and re-execute.  There is no reason this
		// error needs to be returned to the client.
		return nil, false, errors.Errorf("chaincode cache at sequence %d but current sequence is %d, chaincode definition for '%s' changed during invoke", chaincodeInfo.Definition.Sequence, currentSequence, chaincodeName)
	}

	if !chaincodeInfo.Approved {
		return nil, false, errors.Errorf("chaincode definition for '%s' at sequence %d on channel '%s' has not yet been approved by this org", chaincodeName, currentSequence, channelID)
	}

	if chaincodeInfo.InstallInfo == nil {
		if cei.UserRunsCC {
			chaincodeInfo.InstallInfo = &ChaincodeInstallInfo{
				PackageID: chaincodeName + ":" + chaincodeInfo.Definition.EndorsementInfo.Version,
			}
			return chaincodeInfo, true, nil
		}
		return nil, false, errors.Errorf("chaincode definition for '%s' exists, but chaincode is not installed", chaincodeName)
	}

	return chaincodeInfo, true, nil
}

// ChaincodeEndorsementInfo returns the information necessary to handle a chaincode invocation request, as well as a function to
// enforce security checks on the chaincode (in case the definition is from the legacy lscc).
func (cei *ChaincodeEndorsementInfoSource) ChaincodeEndorsementInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (*ChaincodeEndorsementInfo, error) {
	if cei.BuiltinSCCs.IsSysCC(chaincodeName) {
		return &ChaincodeEndorsementInfo{
			Version:           scc.SysCCVersion,
			EndorsementPlugin: "escc",
			EnforceInit:       false,
			ChaincodeID:       scc.ChaincodeID(chaincodeName),
		}, nil
	}

	// return legacy cc endorsement info if V20 is not enabled

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Install the chaincode package on the peer: `peer lifecycle chaincode install <package.tar.gz>`.
  2. Verify with `peer lifecycle chaincode queryinstalled` that a package with the approved packageID exists.
  3. If using external builders, ensure the peer is configured with UserRunsCC/external builder support and the package artifacts are present.
  4. If a new peer was added, re-install chaincode packages on it before it endorses.

Example fix

// before: peer has definition but no package
// (endorsement fails)
// after
peer lifecycle chaincode install mycc.v1.0.tgz
peer lifecycle chaincode queryinstalled  # confirm Package ID matches approval
Defensive patterns

Strategy: validation

Validate before calling

// shell: verify the approved packageID is installed on this peer before endorsing
peer lifecycle chaincode queryinstalled
# ensure the Package ID from `checkcommitreadiness`/approval appears here

Try / catch

err := endorse(...)
if err != nil && strings.Contains(err.Error(), "chaincode is not installed") {
  // install package then retry
}

Prevention

When it happens

Trigger: ChaincodeEndorsementInfo -> CachedChaincodeInfo on a peer where the definition is approved and committed, but `peer lifecycle chaincode install` was never executed, and UserRunsCC=false so no synthetic install info is fabricated.

Common situations: Org approved and committed but forgot to install the package on all endorsing peers; new/replacement peer added to org without installing chaincode; external builder intended but UserRunsCC not enabled / package not present.

Related errors


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