paperclipai/paperclip · error · Error

Output directory already exists and is not empty: ${outputDi

Error message

Output directory already exists and is not empty: ${outputDir}

What it means

ensureEmptyOutputDirectory throws when the target path is an existing directory that already contains entries, to prevent silently merging new export files with old content.

Source

Thrown at cli/src/commands/client/feedback.ts:563

function padRight(value: string, width: number): string {
  return `${value}${" ".repeat(Math.max(0, width - value.length))}`;
}

function defaultFeedbackExportDirName(): string {
  const iso = new Date().toISOString().replace(/[-:]/g, "").replace(/\.\d{3}Z$/, "Z");
  return `feedback-export-${iso}`;
}

async function ensureEmptyOutputDirectory(outputDir: string): Promise<void> {
  try {
    const info = await stat(outputDir);
    if (!info.isDirectory()) {
      throw new Error(`Output path already exists and is not a directory: ${outputDir}`);
    }
    const entries = await readdir(outputDir);
    if (entries.length > 0) {
      throw new Error(`Output directory already exists and is not empty: ${outputDir}`);
    }
  } catch (error) {
    const message = error instanceof Error ? error.message : "";
    if (/ENOENT/.test(message)) {
      await mkdir(outputDir, { recursive: true });
      return;
    }
    throw error;
  }
}

async function collectJsonFilesForArchive(
  outputDir: string,
  relativePaths: string[],
): Promise<Record<string, string>> {
  const files: Record<string, string> = {};
  for (const relativePath of relativePaths) {
    const normalized = relativePath.replace(/\\/g, "/");

View on GitHub (pinned to 67001ec6eb)

Solutions

  1. Empty or remove the existing directory first.
  2. Choose a new --output path.
  3. Omit --output to get a fresh timestamped default directory.

Example fix

// before
paperclipai feedback trace export --output ./traces
// after
rm -rf ./traces && paperclipai feedback trace export --output ./traces
Defensive patterns

Strategy: validation

Validate before calling

import {readdir} from 'node:fs/promises';
const entries = await readdir(outputDir);
if (entries.length > 0) throw new Error(`Output directory already exists and is not empty: ${outputDir}`);

Prevention

When it happens

Trigger: Passing --output <dir> where <dir> exists and is non-empty.

Common situations: Re-running an export into the same directory; pointing --output at a project folder.

Related errors


AI-assisted analysis of paperclipai/paperclip@67001ec6eb (2026-08-12). Data as JSON: /api/errors/a9c1ad5d516d057b. Report an issue: GitHub.