{"record":{"id":"605a88470fa49e11","repo":"hyperledger/fabric","slug":"error-reading-chaincode-directory-at-s","errorCode":null,"errorMessage":"error reading chaincode directory at %s","messagePattern":"error reading chaincode directory at (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"core/chaincode/persistence/persistence.go","lineNumber":228,"sourceCode":"\treturn s.ReadWriter.Remove(ccInstallPkgPath)\n}\n\n// CodePackageNotFoundErr is the error returned when a code package cannot\n// be found in the persistence store\ntype CodePackageNotFoundErr struct {\n\tPackageID string\n}\n\nfunc (e CodePackageNotFoundErr) Error() string {\n\treturn fmt.Sprintf(\"chaincode install package '%s' not found\", e.PackageID)\n}\n\n// ListInstalledChaincodes returns an array with information about the\n// chaincodes installed in the persistence store\nfunc (s *Store) ListInstalledChaincodes() ([]chaincode.InstalledChaincode, error) {\n\tfiles, err := s.ReadWriter.ReadDir(s.Path)\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"error reading chaincode directory at %s\", s.Path)\n\t}\n\n\tinstalledChaincodes := []chaincode.InstalledChaincode{}\n\tfor _, file := range files {\n\t\tif instCC, isInstCC := installedChaincodeFromFilename(file.Name()); isInstCC {\n\t\t\tinstalledChaincodes = append(installedChaincodes, instCC)\n\t\t}\n\t}\n\treturn installedChaincodes, nil\n}\n\n// GetChaincodeInstallPath returns the path where chaincodes\n// are installed\nfunc (s *Store) GetChaincodeInstallPath() string {\n\treturn s.Path\n}\n\n// PackageID returns the package ID with the label and hash of the chaincode install package","sourceCodeStart":210,"sourceCodeEnd":246,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/persistence/persistence.go#L210-L246","documentation":"ListInstalledChaincodes wraps ReadDir failures with 'error reading chaincode directory at %s'. It cannot enumerate the installed packages, so any listing (e.g. _lifecycle QueryInstalledChaincodes) fails.","triggerScenarios":"Calling ListInstalledChaincodes() when os.ReadDir(s.Path) fails: directory missing (deleted externally), permission denied, or path is not a directory.","commonSituations":"Admin manually deleted the _lifecycle chaincodes dir; permissions reset by redeploy without volume; mount point not yet mounted so the dir is absent at startup.","solutions":["Recreate the directory with correct ownership (it is normally created by Initialize with 0o750)","Restore correct permissions for the peer user on the chaincodes path","Check the volume/mount is present before starting the peer","Run queryinstalled again after the filesystem is repaired"],"exampleFix":"// before\nrm -rf lifecycle/chaincodes  (dir gone)\n// after\nmkdir -p lifecycle/chaincodes && chown peer:peer lifecycle/chaincodes","handlingStrategy":"validation","validationCode":"st, err := os.Stat(storePath)\nif err != nil { return fmt.Errorf(\"missing dir: %w\", err) }\nif !st.IsDir() { return fmt.Errorf(\"%s is not a directory\", storePath) }","typeGuard":"func dirReadable(p string) bool { st, err := os.Stat(p); return err == nil && st.IsDir() }","tryCatchPattern":"ccs, err := store.ListInstalledChaincodes()\nif err != nil && strings.Contains(err.Error(), \"error reading chaincode directory\") {\n  os.MkdirAll(storePath, 0o750) // repair then retry\n}","preventionTips":["Never delete lifecycle/chaincodes manually","Mount volumes before the peer starts","Include the dir in backup/restore procedures"],"tags":["filesystem","readdir","fabric","lifecycle"],"backgroundTag":"directory-not-found","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"}