Egonex-AI/Understand-Anything · error · CliUsageError

Repository path is not a directory: ${repoValue}

Error message

Repository path is not a directory: ${repoValue}

What it means

CliUsageError thrown by parseArgs when the resolved repository path exists but statSync reports it is not a directory. The benchmark needs to walk a directory tree, so a file, device, or symlink-to-file is rejected.

Source

Thrown at scripts/lib/large-repo-benchmark.mjs:260

    }
    repoValue = arg;
  }

  if (help) return { help: true };
  if (!repoValue) throw new CliUsageError('A repository path is required');
  if (outputValue === null || outputValue.trim() === '') {
    throw new CliUsageError('--output is required and must be non-empty');
  }
  if (!Number.isInteger(concurrency) || concurrency < 1 || concurrency > 32) {
    throw new CliUsageError('--concurrency must be an integer between 1 and 32');
  }

  const repoRoot = resolve(cwd, repoValue);
  if (!existsSync(repoRoot)) {
    throw new CliUsageError(`Repository path does not exist: ${repoValue}`);
  }
  if (!statSync(repoRoot).isDirectory()) {
    throw new CliUsageError(`Repository path is not a directory: ${repoValue}`);
  }

  const outputPath = resolve(cwd, outputValue);
  const markdownPath = resolve(
    cwd,
    outputPath.toLowerCase().endsWith('.json')
      ? `${outputPath.slice(0, -'.json'.length)}.md`
      : `${outputPath}.md`,
  );
  if (isPathInsideOrEqual(repoRoot, outputPath)) {
    throw new CliUsageError('--output must be outside the subject repository');
  }
  if (isPathInsideOrEqual(repoRoot, markdownPath)) {
    throw new CliUsageError('Markdown report path must be outside the subject repository');
  }

  return {
    help: false,

View on GitHub (pinned to 32944829e7)

Solutions

  1. Point at the repository root directory (the working tree), not a file within it.
  2. Resolve symlinks to confirm the target is a directory.
  3. Use an absolute path to the directory to avoid ambiguity.
  4. If the repo is a submodule, ensure the path is the checked-out working tree.

Example fix

# before
node benchmark-large-repo.mjs /abs/repo/README.md --output out.json
# after
node benchmark-large-repo.mjs /abs/repo --output out.json
Defensive patterns

Strategy: validation

Validate before calling

import { statSync } from 'node:fs';
if (!statSync(resolve(cwd, repoValue)).isDirectory()) { /* reject early */ }

Try / catch

try { const opts = parseArgs(argv); } catch (e) { if ((e as Error).name === 'CliUsageError') { console.error(e.message); process.exit(2); } throw e; }

Prevention

When it happens

Trigger: Passing a path to a file (e.g. a .git file instead of the working tree), a broken symlink, a special file, or a path that resolves to a regular file via a symlink.

Common situations: Pointing at a file inside the repo rather than the repo root; a symlink that resolves to a file; copying a path from documentation that referred to a file; misinterpreting a submodule pointer.

Related errors


AI-assisted analysis of Egonex-AI/Understand-Anything@32944829e7 (2026-08-12). Data as JSON: /api/errors/494755b975eda6dc. Report an issue: GitHub.