paperclipai/paperclip · error · Error

Output directory already exists and is not empty

Error message

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

What it means

The feedback export output directory exists and contains entries, so the empty-directory guard refuses to overwrite previous export contents.

Solutions

  1. Choose an empty/non-existent output directory, or clear the existing one.
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at cli/src/commands/client/feedback.ts:563 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: 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 120ae5428f)