{"record":{"id":"5557012f28215fc3","repo":"hyperledger/fabric","slug":"s-already-exists-in-s-choose-a-different-locati-555701","errorCode":null,"errorMessage":"%s already exists in %s. Choose a different location or remove the existing results. Aborting verify","messagePattern":"(.+?) already exists in (.+?)\\. Choose a different location or remove the existing results\\. Aborting verify","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/ledgerutil/verify/verify.go","lineNumber":65,"sourceCode":"\n\t// Retrieve the list of the ledgers (i.e. channels) available\n\tlist, err := blockStoreProvider.List()\n\tif err != nil {\n\t\treturn false, err\n\t}\n\n\t// Iterate over the channels\n\tfor _, ledgerId := range list {\n\t\t// Create Output Directory\n\t\toutputDirName := fmt.Sprintf(\"%s_verification_result\", ledgerId)\n\t\toutputDirPath := filepath.Join(outputDir, outputDirName)\n\n\t\tempty, err := fileutil.CreateDirIfMissing(outputDirPath)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tif !empty {\n\t\t\treturn false, errors.Errorf(\"%s already exists in %s. Choose a different location or remove the existing results. Aborting verify\", outputDirName, outputDir)\n\t\t}\n\n\t\t// Open block provider\n\t\tstore, err := blockStoreProvider.Open(ledgerId)\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\t\tdefer store.Shutdown()\n\n\t\tinfo, err := store.GetBlockchainInfo()\n\t\tif err != nil {\n\t\t\treturn false, err\n\t\t}\n\n\t\tfirstBlockNumber := getFirstBlockNumberInLedger(info)\n\n\t\titerator, err := store.RetrieveBlocks(firstBlockNumber)\n\t\tif err != nil {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/hyperledger/fabric/blob/2736b63f8fd5932511d56fe68b7039d15977f7f6/internal/ledgerutil/verify/verify.go#L47-L83","documentation":"VerifyLedger writes its results into an outputDirName subdirectory under the user-provided output directory. If that directory already exists and is non-empty, previous (or stray) results would be mixed with new ones, so verification aborts and asks for a different location.","triggerScenarios":"Running the verify command with an output directory where a subdirectory named after the results (outputDirName) already exists and contains files; CreateDirIfMissing reports empty==false for that path.","commonSituations":"Re-running verify with the same output flag after a previous run, resuming an interrupted verification whose partial output was left behind, or pointing at a directory used by another tool.","solutions":["Remove the existing results directory before rerunning (rm -rf <outputDir>/<outputDirName>)","Choose a different, empty output directory via the command's output flag","Verify the previous run is not still in progress writing to that location","If prior results are wanted, move/archive them instead of deleting"],"exampleFix":"// before\nverify --outputDir /tmp/results  # /tmp/results/output already contains old files\n// after\nrm -rf /tmp/results/output\nverify --outputDir /tmp/results","handlingStrategy":"validation","validationCode":"func verifyOutputDirFree(outputDir, resultsName string) error {\n\tinfo, err := os.Stat(filepath.Join(outputDir, resultsName))\n\tif os.IsNotExist(err) {\n\t\treturn nil\n\t}\n\tif err != nil {\n\t\treturn err\n\t}\n\tif info.IsDir() {\n\t\treturn fmt.Errorf(\"%s exists in %s: remove or choose another output dir\", resultsName, outputDir)\n\t}\n\treturn nil\n}","typeGuard":"func outputDirUsable(outputDir, resultsName string) bool {\n\t_, err := os.Stat(filepath.Join(outputDir, resultsName))\n\treturn os.IsNotExist(err)\n}","tryCatchPattern":"if err := verifyOutputDirFree(outputDir, \"output\"); err != nil {\n\treturn err // prompt user to clean or relocate before running verify\n}\nok, err := verify.VerifyLedger(ctx, config, ledgerID, inputDir, outputDir, ...)","preventionTips":["Use a fresh output directory per run (timestamped names help)","Delete or archive prior results before re-running verify","Confirm no other verify process is writing to the same output dir","Never point verify's output at a shared or pre-populated directory"],"tags":["hyperledger-fabric","filesystem","output-directory","idempotency"],"backgroundTag":"output-directory-not-empty","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"}