{"record":{"id":"dcf5f578bd410f36","repo":"hyperledger/fabric","slug":"cannot-init-crypto-specified-path-s-is-not-a-d","errorCode":null,"errorMessage":"cannot init crypto, specified path \"%s\" is not a directory","messagePattern":"cannot init crypto, specified path \"(.+?)\" is not a directory","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/peer/common/common.go","lineNumber":179,"sourceCode":"\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\n\t}\n\terr = mspmgmt.GetLocalMSP(factory.GetDefault()).Setup(conf)","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/peer/common/common.go#L161-L197","documentation":"InitCrypto requires mspMgrConfigDir to be a directory containing MSP material. When os.Stat succeeds but fi.IsDir() is false, it returns this error because a file (or symlink to a file) was given where the MSP directory was expected.","triggerScenarios":"Calling InitCrypto with mspMgrConfigPath (CORE_PEER_MSPCONFIGPATH or the -o/--file flag) set to a regular file — e.g. pointing at a tarball, a config file, or admincerts file instead of the msp directory.","commonSituations":"Setting CORE_PEER_MSPCONFIGPATH to an admin signing identity file instead of the MSP folder; pointing at 'msp' where 'msp' is actually a file created by a bad extraction; clipboard/typos pasting a file path rather than directory.","solutions":["Point CORE_PEER_MSPCONFIGPATH at the msp directory itself, not a file inside it.","Verify with: test -d \"$CORE_PEER_MSPCONFIGPATH\" && echo dir || echo not-a-dir.","Re-extract the MSP archive if the 'msp' path is a leftover file (tar -xzf in the correct location).","For admin operations, keep the admin identity dir separate from the peer's local MSP dir."],"exampleFix":"// before\nexport CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp/admincerts/Admin@org1-cert.pem\n\n// after\nexport CORE_PEER_MSPCONFIGPATH=/etc/hyperledger/fabric/msp","handlingStrategy":"validation","validationCode":"mspDir := os.Getenv(\"CORE_PEER_MSPCONFIGPATH\")\nfi, err := os.Stat(mspDir)\nif err == nil && !fi.IsDir() {\n\treturn fmt.Errorf(\"%q is a file; CORE_PEER_MSPCONFIGPATH must be the msp directory\", mspDir)\n}","typeGuard":null,"tryCatchPattern":"if err := common.InitCrypto(mspDir, localMSPID, localMSPType); err != nil {\n\tif strings.Contains(err.Error(), \"is not a directory\") {\n\t\treturn fmt.Errorf(\"CORE_PEER_MSPCONFIGPATH must point at the msp folder, not a file: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Point CORE_PEER_MSPCONFIGPATH at the directory containing keystore/signcerts/admincerts, never a file.","Use tab-completion with trailing '/' when setting MSP paths to force directories.","Check archive extractions: a stray 'msp' file often means a bad tar extraction.","Script sanity checks: [ -d \"$CORE_PEER_MSPCONFIGPATH\" ] || exit 1."],"tags":["hyperledger-fabric","msp","filesystem","configuration"],"backgroundTag":"path-is-not-a-directory","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"}