{"record":{"id":"6865832035208ad9","repo":"hyperledger/fabric","slug":"cannot-init-crypto-specified-path-s-does-not-e","errorCode":null,"errorMessage":"cannot init crypto, specified path \"%s\" does not exist or cannot be accessed: %v","messagePattern":"cannot init crypto, specified path \"(.+?)\" does not exist or cannot be accessed: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/common/common.go","lineNumber":177,"sourceCode":"\topts := viper.DecodeHook(mapstructure.ComposeDecodeHookFunc(\n\t\tmapstructure.StringToTimeDurationHookFunc(),\n\t\tmapstructure.StringToWeakSliceHookFunc(\",\"),\n\t\tfactory.StringToKeyIds(),\n\t))\n\n\tif err := subv.Unmarshal(&bccspConfig, opts); err != nil {\n\t\treturn errors.WithMessage(err, \"could not decode peer BCCSP configuration\")\n\t}\n\n\treturn nil\n}\n\n// InitCrypto initializes crypto for this peer\nfunc InitCrypto(mspMgrConfigDir, localMSPID, localMSPType string) error {\n\t// Check whether msp folder exists\n\tfi, err := os.Stat(mspMgrConfigDir)\n\tif err != nil {\n\t\treturn errors.Errorf(\"cannot init crypto, specified path \\\"%s\\\" does not exist or cannot be accessed: %v\", mspMgrConfigDir, err)\n\t} else if !fi.IsDir() {\n\t\treturn errors.Errorf(\"cannot init crypto, specified path \\\"%s\\\" is not a directory\", mspMgrConfigDir)\n\t}\n\t// Check whether localMSPID exists\n\tif localMSPID == \"\" {\n\t\treturn errors.New(\"the local MSP must have an ID\")\n\t}\n\n\t// Init the BCCSP\n\tbccspConfig := factory.GetDefaultOpts()\n\terr = InitBCCSPConfig(bccspConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\tconf, err := msp.GetLocalMspConfigWithType(mspMgrConfigDir, bccspConfig, localMSPID, localMSPType)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/common/common.go#L159-L195","documentation":"InitCrypto validates the local MSP directory before initializing crypto. It calls os.Stat(mspMgrConfigDir) and returns this wrapped error when the stat fails — the path does not exist or is inaccessible (permissions). The original os error is appended for diagnosis.","triggerScenarios":"Calling InitCrypto (via peer InitCmd) with a --peer-chaincodedev / MSP dir flag (mspMgrConfigDir, e.g. from CORE_PEER_MSPCONFIGPATH or fileblock-path) that points at a nonexistent or unreadable path.","commonSituations":"CORE_PEER_MSPCONFIGPATH pointing to a directory not mounted/copied into the container; typo in the MSP path; running the peer before 'cryptogen generate' has produced the MSP folders; permission denied after copying MSP material as another user.","solutions":["Check the path exists: ls -la $CORE_PEER_MSPCONFIGPATH; fix the value if it's wrong.","Generate the MSP material if missing (cryptogen generate --output=... or copy from the org's MSP).","Fix filesystem permissions (chmod/chown) so the peer process user can read the directory.","In Docker/K8s, verify the volume mount that provides the MSP dir is present and points at the right host path."],"exampleFix":"// before\nexport CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp  # does not exist\n\n// after\nexport CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/peerOrganizations/org1.example.com/peers/peer0.org1.example.com/msp\nls -d $CORE_PEER_MSPCONFIGPATH  # verify first","handlingStrategy":"validation","validationCode":"mspDir := os.Getenv(\"CORE_PEER_MSPCONFIGPATH\")\nif fi, err := os.Stat(mspDir); err != nil {\n\treturn fmt.Errorf(\"MSP path %q inaccessible: %v\", mspDir, err)\n} else if !fi.IsDir() {\n\treturn fmt.Errorf(\"MSP path %q is not a directory\", mspDir)\n}","typeGuard":null,"tryCatchPattern":"if err := common.InitCrypto(mspDir, localMSPID, localMSPType); err != nil {\n\tif strings.Contains(err.Error(), \"does not exist or cannot be accessed\") {\n\t\tlog.Fatalf(\"check CORE_PEER_MSPCONFIGPATH=%q (generate MSP with cryptogen or fix mount/permissions): %v\", mspDir, err)\n\t}\n\treturn err\n}","preventionTips":["Run 'test -d' on the MSP path in entrypoint scripts before starting the peer.","Generate MSP material (cryptogen or fabric-ca) before first peer start.","Fix ownership/permissions when copying MSP dirs between hosts or containers.","Verify volume mounts in Docker Compose/K8s point at the parent of the msp directory."],"tags":["hyperledger-fabric","msp","filesystem","configuration"],"backgroundTag":"file-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"}