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 verify

What it means

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.

Source

Thrown at internal/ledgerutil/verify/verify.go:65

	// Retrieve the list of the ledgers (i.e. channels) available
	list, err := blockStoreProvider.List()
	if err != nil {
		return false, err
	}

	// Iterate over the channels
	for _, ledgerId := range list {
		// Create Output Directory
		outputDirName := fmt.Sprintf("%s_verification_result", ledgerId)
		outputDirPath := filepath.Join(outputDir, outputDirName)

		empty, err := fileutil.CreateDirIfMissing(outputDirPath)
		if err != nil {
			return false, err
		}
		if !empty {
			return false, errors.Errorf("%s already exists in %s. Choose a different location or remove the existing results. Aborting verify", outputDirName, outputDir)
		}

		// Open block provider
		store, err := blockStoreProvider.Open(ledgerId)
		if err != nil {
			return false, err
		}
		defer store.Shutdown()

		info, err := store.GetBlockchainInfo()
		if err != nil {
			return false, err
		}

		firstBlockNumber := getFirstBlockNumberInLedger(info)

		iterator, err := store.RetrieveBlocks(firstBlockNumber)
		if err != nil {

View on GitHub (pinned to 2736b63f8f)

Solutions

  1. Remove the existing results directory before rerunning (rm -rf <outputDir>/<outputDirName>)
  2. Choose a different, empty output directory via the command's output flag
  3. Verify the previous run is not still in progress writing to that location
  4. If prior results are wanted, move/archive them instead of deleting

Example fix

// before
verify --outputDir /tmp/results  # /tmp/results/output already contains old files
// after
rm -rf /tmp/results/output
verify --outputDir /tmp/results
Defensive patterns

Strategy: validation

Validate before calling

func verifyOutputDirFree(outputDir, resultsName string) error {
	info, err := os.Stat(filepath.Join(outputDir, resultsName))
	if os.IsNotExist(err) {
		return nil
	}
	if err != nil {
		return err
	}
	if info.IsDir() {
		return fmt.Errorf("%s exists in %s: remove or choose another output dir", resultsName, outputDir)
	}
	return nil
}

Type guard

func outputDirUsable(outputDir, resultsName string) bool {
	_, err := os.Stat(filepath.Join(outputDir, resultsName))
	return os.IsNotExist(err)
}

Try / catch

if err := verifyOutputDirFree(outputDir, "output"); err != nil {
	return err // prompt user to clean or relocate before running verify
}
ok, err := verify.VerifyLedger(ctx, config, ledgerID, inputDir, outputDir, ...)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hyperledger/fabric@2736b63f8f (2026-09-04). Data as JSON: /api/errors/5557012f28215fc3. Report an issue: GitHub.