{"record":{"id":"2e605e1669e90ed1","repo":"hyperledger/fabric","slug":"could-not-create-lifecycle-chaincodes-install-pat","errorCode":null,"errorMessage":"Could not create _lifecycle chaincodes install path: %s","messagePattern":"Could not create _lifecycle chaincodes install path: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"core/chaincode/persistence/persistence.go","lineNumber":155,"sourceCode":"\tstore.Initialize()\n\treturn store\n}\n\n// Initialize checks for the existence of the _lifecycle chaincodes\n// directory and creates it if it has not yet been created.\nfunc (s *Store) Initialize() {\n\tvar (\n\t\texists bool\n\t\terr    error\n\t)\n\tif exists, err = s.ReadWriter.Exists(s.Path); exists {\n\t\treturn\n\t}\n\tif err != nil {\n\t\tpanic(fmt.Sprintf(\"Initialization of chaincode store failed: %s\", err))\n\t}\n\tif err = s.ReadWriter.MakeDir(s.Path, 0o750); err != nil {\n\t\tpanic(fmt.Sprintf(\"Could not create _lifecycle chaincodes install path: %s\", err))\n\t}\n}\n\n// Save persists chaincode install package bytes. It returns\n// the hash of the chaincode install package\nfunc (s *Store) Save(label string, ccInstallPkg []byte) (string, error) {\n\tpackageID := PackageID(label, ccInstallPkg)\n\n\tccInstallPkgFileName := CCFileName(packageID)\n\tccInstallPkgFilePath := filepath.Join(s.Path, ccInstallPkgFileName)\n\n\tif exists, _ := s.ReadWriter.Exists(ccInstallPkgFilePath); exists {\n\t\t// chaincode install package was already installed\n\t\treturn packageID, nil\n\t}\n\n\tif err := s.ReadWriter.WriteFile(s.Path, ccInstallPkgFileName, ccInstallPkg); err != nil {\n\t\terr = errors.Wrapf(err, \"error writing chaincode install package to %s\", ccInstallPkgFilePath)","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/core/chaincode/persistence/persistence.go#L137-L173","documentation":"This is a panic, not a returned error, emitted by persistence.Store.Initialize when the ReadWriter fails to create the _lifecycle chaincodes install directory (s.Path). The store cannot function without its on-disk directory, so initialization aborts the process. The wrapped OS error is embedded in the panic message via %s.","triggerScenarios":"NewStore -> Initialize calls ReadWriter.MakeDir(s.Path, 0o750) and the underlying os.MkdirAll fails: invalid path, permission denied on the parent, path is a file, or read-only filesystem.","commonSituations":"peer data directory configured with wrong permissions; peerLedger/chaincodes path owned by another user (e.g. running peer in container as non-root against a root-owned volume); DOCKER_VM/path misconfiguration; disk mounted read-only.","solutions":["Fix permissions/ownership on the parent directory so the peer process can create s.Path (e.g. chown -R the peer data dir to the peer user)","Verify the configured path is valid and not an existing regular file; correct peer core.yaml or store construction path","Check the filesystem is writable and not full or mounted read-only","Wrap store construction in a recover() at the caller if you embed the library, so the panic surfaces as a controlled error"],"exampleFix":"// before\npeer:\n  fileSystemPath: /var/hyperledger/production  (dir owned by root, peer runs as non-root)\n// after\n$ chown -R peer:peer /var/hyperledger/production","handlingStrategy":"try-catch","validationCode":"if st, err := os.Stat(path); err == nil && !st.IsDir() { return fmt.Errorf(\"path %s is not a directory\", path) }\nif err := unix.Access(filepath.Dir(path), unix.W_OK); err != nil { return fmt.Errorf(\"parent %s not writable\", filepath.Dir(path)) }","typeGuard":"func canCreateDir(p string) bool { if st, err := os.Stat(p); err == nil { return st.IsDir() }; return unix.Access(filepath.Dir(p), unix.W_OK) == nil }","tryCatchPattern":"func safeNewStore() (s *persistence.Store, err error) {\n  defer func() { if r := recover(); r != nil { err = fmt.Errorf(\"store init failed: %v\", r) } }()\n  return persistence.NewStore(path, rw), nil\n}","preventionTips":["Run the peer as a user that owns the fileSystemPath","chown the data directory after container image updates","Check volume mount options are not ro","Verify path is not an existing regular file before startup"],"tags":["filesystem","panic","permissions","fabric"],"backgroundTag":"mkdir-permission-denied","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"}