{"record":{"id":"a7471b2b7375aa40","repo":"hyperledger/fabric","slug":"chaincode-definition-for-s-exists-but-chaincod","errorCode":null,"errorMessage":"chaincode definition for '%s' exists, but chaincode is not installed","messagePattern":"chaincode definition for '(.+?)' exists, but chaincode is not installed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/endorsement_info.go","lineNumber":99,"sourceCode":"\t\t// TODO this is a transient error which indicates that this query executor is executing against a chaincode\n\t\t// whose definition has already changed (the cache may be ahead of the committed state, but never behind).  In this\n\t\t// case, we should simply abort the tx, and re-acquire a query executor and re-execute.  There is no reason this\n\t\t// error needs to be returned to the client.\n\t\treturn 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)\n\t}\n\n\tif !chaincodeInfo.Approved {\n\t\treturn 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)\n\t}\n\n\tif chaincodeInfo.InstallInfo == nil {\n\t\tif cei.UserRunsCC {\n\t\t\tchaincodeInfo.InstallInfo = &ChaincodeInstallInfo{\n\t\t\t\tPackageID: chaincodeName + \":\" + chaincodeInfo.Definition.EndorsementInfo.Version,\n\t\t\t}\n\t\t\treturn chaincodeInfo, true, nil\n\t\t}\n\t\treturn nil, false, errors.Errorf(\"chaincode definition for '%s' exists, but chaincode is not installed\", chaincodeName)\n\t}\n\n\treturn chaincodeInfo, true, nil\n}\n\n// ChaincodeEndorsementInfo returns the information necessary to handle a chaincode invocation request, as well as a function to\n// enforce security checks on the chaincode (in case the definition is from the legacy lscc).\nfunc (cei *ChaincodeEndorsementInfoSource) ChaincodeEndorsementInfo(channelID, chaincodeName string, qe ledger.SimpleQueryExecutor) (*ChaincodeEndorsementInfo, error) {\n\tif cei.BuiltinSCCs.IsSysCC(chaincodeName) {\n\t\treturn &ChaincodeEndorsementInfo{\n\t\t\tVersion:           scc.SysCCVersion,\n\t\t\tEndorsementPlugin: \"escc\",\n\t\t\tEnforceInit:       false,\n\t\t\tChaincodeID:       scc.ChaincodeID(chaincodeName),\n\t\t}, nil\n\t}\n\n\t// return legacy cc endorsement info if V20 is not enabled","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/endorsement_info.go#L81-L117","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: peer has definition but no package\n// (endorsement fails)\n// after\npeer lifecycle chaincode install mycc.v1.0.tgz\npeer lifecycle chaincode queryinstalled  # confirm Package ID matches approval","handlingStrategy":"validation","validationCode":"// shell: verify the approved packageID is installed on this peer before endorsing\npeer lifecycle chaincode queryinstalled\n# ensure the Package ID from `checkcommitreadiness`/approval appears here","typeGuard":null,"tryCatchPattern":"err := endorse(...)\nif err != nil && strings.Contains(err.Error(), \"chaincode is not installed\") {\n  // install package then retry\n}","preventionTips":["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."],"tags":["hyperledger-fabric","chaincode-install","chaincode-lifecycle","endorsement"],"backgroundTag":"chaincode-not-installed","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"}