{"record":{"id":"ecbda1eb95be878d","repo":"hyperledger/fabric","slug":"could-not-find-chaincode-with-package-id-s","errorCode":null,"errorMessage":"could not find chaincode with package id '%s'","messagePattern":"could not find chaincode with package id '(.+?)'","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/lifecycle/cache.go","lineNumber":424,"sourceCode":"\n// GetInstalledChaincode returns all of the information about a specific\n// installed chaincode.\nfunc (c *Cache) GetInstalledChaincode(packageID string) (*chaincode.InstalledChaincode, error) {\n\tc.mutex.RLock()\n\tdefer c.mutex.RUnlock()\n\n\tfor _, lc := range c.localChaincodes {\n\t\tif lc.Info == nil {\n\t\t\t// the update function adds an entry to localChaincodes\n\t\t\t// even if it isn't yet installed\n\t\t\tcontinue\n\t\t}\n\t\tif lc.Info.PackageID == packageID {\n\t\t\treturn lc.ToInstalledChaincode(), nil\n\t\t}\n\t}\n\n\treturn nil, errors.Errorf(\"could not find chaincode with package id '%s'\", packageID)\n}\n\n// update should only be called with the write lock already held\nfunc (c *Cache) update(initializing bool, channelID string, dirtyChaincodes map[string]struct{}, qe ledger.SimpleQueryExecutor) error {\n\tchannelCache, ok := c.definedChaincodes[channelID]\n\tif !ok {\n\t\tchannelCache = &ChannelCache{\n\t\t\tChaincodes:        map[string]*CachedChaincodeDefinition{},\n\t\t\tInterestingHashes: map[string]string{},\n\t\t}\n\t\tc.definedChaincodes[channelID] = channelCache\n\t}\n\n\tpublicState := &SimpleQueryExecutorShim{\n\t\tNamespace:           LifecycleNamespace,\n\t\tSimpleQueryExecutor: qe,\n\t}\n","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/lifecycle/cache.go#L406-L442","documentation":"GetInstalledChaincode scans the locally installed chaincode packages for a matching PackageID and throws this when no installed package matches. The package ID is derived from hashing the package contents, so only packages installed on this peer's filesystem can be found.","triggerScenarios":"Calling GetInstalledChaincode(packageID) with a PackageID that was never installed on this peer, or one installed after the call / on a different peer.","commonSituations":"Copy-pasting a PackageID from another peer's output; package installed but peer restarted with a different peerFileSystem path (CORE_PEER_FILESYSTEMPATH); package removed or install DB out of sync.","solutions":["Run 'peer lifecycle chaincode install <package.tar.gz>' on this peer to install the package.","List installed packages ('peer lifecycle chaincode queryinstalled') and use a PackageID actually present in the output.","Verify CORE_PEER_FILESYSTEMPATH points to the directory containing the installed packages (lifecycle/chaincodes).","Reinstall if the install DB is inconsistent (peer upgraded or filesystem copied partially)."],"exampleFix":"// before: hardcoded ID from another peer\npkg, err := cache.GetInstalledChaincode(\"hash:1234...\")\n// after: resolve from this peer's installed list\ninstalled, _ := lc.ListInstalledChaincodes()\nfor _, ic := range installed {\n    if ic.PackageID == wantID { pkg, err = cache.GetInstalledChaincode(wantID); break }\n}","handlingStrategy":"validation","validationCode":"installed, err := lc.ListInstalledChaincodes()\nif err != nil { return err }\nfound := false\nfor _, ic := range installed {\n    if ic.PackageID == packageID { found = true; break }\n}\nif !found { return fmt.Errorf(\"package %s not installed on this peer\", packageID) }","typeGuard":null,"tryCatchPattern":"pkg, err := cache.GetInstalledChaincode(packageID)\nif err != nil && strings.Contains(err.Error(), \"could not find chaincode with package id\") {\n    return nil, ErrPackageNotInstalled\n}","preventionTips":["Capture PackageID from 'queryinstalled' output on the same peer that will serve it.","Never hardcode package IDs; resolve them per-peer at runtime.","Check CORE_PEER_FILESYSTEMPATH consistency across peer restarts."],"tags":["fabric","package-not-found","lifecycle"],"backgroundTag":"chaincode-package-missing","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"}