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 enabledView on GitHub (pinned to 2736b63f8f)
Solutions
- Install the chaincode package on the peer: `peer lifecycle chaincode install <package.tar.gz>`.
- Verify with `peer lifecycle chaincode queryinstalled` that a package with the approved packageID exists.
- If using external builders, ensure the peer is configured with UserRunsCC/external builder support and the package artifacts are present.
- 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
- Install the package on all endorsing peers, not just one.
- Automate: after install, assert queryinstalled contains the approved Package ID.
- Re-install chaincode when adding or replacing peers.
- If using external builders, confirm UserRunsCC/external-builder config before commit.
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
- could not get channel config for channel '%s'
- failed listing installed chaincodes
- could not get channel config for channel '%s'
- could not get application config for channel '%s'
- no such collection '%s'
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/a7471b2b7375aa40.
Report an issue: GitHub.