hyperledger/fabric · error
%s already exists in %s. Choose a different location or remo
Error message
%s already exists in %s. Choose a different location or remove the existing results. Aborting identifytxs
What it means
IdentifyTxs writes results into a directory named '<ledgerid>_identified_transactions' under the given output location. CreateDirIfMissing reports whether the directory already existed and was non-empty; if it does, the tool refuses to overwrite prior results and returns this error.
Source
Thrown at internal/ledgerutil/identifytxs/identifytxs.go:60
var records *models.DiffRecordList
records, err := jsonrw.LoadRecords(recPath)
if err != nil {
return 0, 0, err
}
if len(records.DiffRecords) == 0 {
return 0, 0, errors.Errorf("no records were read. JSON record list is either empty or not properly formatted. Aborting identifytxs")
}
// Output directory creation
outputDirName := fmt.Sprintf("%s_identified_transactions", records.Ledgerid)
outputDirPath := filepath.Join(outputDirLoc, outputDirName)
empty, err := fileutil.CreateDirIfMissing(outputDirPath)
if err != nil {
return 0, 0, err
}
if !empty {
return 0, 0, errors.Errorf("%s already exists in %s. Choose a different location or remove the existing results. Aborting identifytxs", outputDirName, outputDirLoc)
}
// Get recordsMap from json
inputKeyMapWrapper, err := generateRecordsMap(records.DiffRecords, outputDirPath)
if err != nil {
return 0, 0, err
}
// Set up block store and block iterator in preparation for traversal
blockStoreProvider, err := getBlockStoreProvider(fsPath)
if err != nil {
return 0, 0, err
}
defer blockStoreProvider.Close()
blockStoreExists, err := blockStoreProvider.Exists(records.Ledgerid)
if err != nil {
return 0, 0, errView on GitHub (pinned to 2736b63f8f)
Solutions
- Remove or move the existing '<ledgerid>_identified_transactions' directory, then rerun
- Pass a different outputDirLoc on the command line
- If it's leftovers from a failed run, verify contents then delete before retrying
Example fix
// before ledgerutil identifytxs ./diff.json ./out // after (previous run present) rm -rf ./out/myledger_identified_transactions ledgerutil identifytxs ./diff.json ./out
Defensive patterns
Strategy: validation
Validate before calling
// Go: ensure the output dir does not already exist (non-empty) before running
outputDir := filepath.Join(outputDirLoc, ledgerid+"_identified_transactions")
if entries, err := os.ReadDir(outputDir); err == nil && len(entries) > 0 {
return fmt.Errorf("output directory %s already exists and is not empty", outputDir)
} Try / catch
if _, _, err := ledgerutil.IdentifyTxs(recPath, outDir); err != nil {
if strings.Contains(err.Error(), "already exists") {
return fmt.Errorf("move/remove %s or choose a new output dir: %w", err, err)
}
return err
} Prevention
- Use a timestamped or unique output directory per run
- Clean up results from failed runs before rerunning
- Script the removal of <ledgerid>_identified_transactions before automated reruns
When it happens
Trigger: Running ledgerutil identifytxs twice with the same output directory location and the same ledger id, without clearing or renaming the previous results directory.
Common situations: Re-running the tool after a failed/partial run; scripted reruns with identical outputDirLoc; two runs targeting the same ledger name in the same output directory.
Related errors
- error writing output
- error truncating the file [%s] to size [%d]
- error opening block file writer for file %s
- failed listing installed chaincodes
- failed to get working directory
AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04).
Data as JSON: /api/errors/cf9296b2ea459694.
Report an issue: GitHub.