Egonex-AI/Understand-Anything · error · CliUsageError

--output is required and must be non-empty

Error message

--output is required and must be non-empty

What it means

CliUsageError thrown by parseArgs when outputValue is null (no --output/-o flag seen) or empty after trim. The output path is required because the benchmark must write its JSON report somewhere deterministic outside the subject repo.

Source

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

      continue;
    }
    if (arg.startsWith('--concurrency=')) {
      concurrency = parseConcurrency(arg.slice('--concurrency='.length));
      continue;
    }
    if (arg.startsWith('-')) {
      throw new CliUsageError(`Unknown option: ${arg}`);
    }
    if (repoValue) {
      throw new CliUsageError(`Unexpected positional argument: ${arg}`);
    }
    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`

View on GitHub (pinned to 32944829e7)

Solutions

  1. Add --output <path> (or -o <path>) pointing to the JSON report location.
  2. Use the '=' form: --output=reports/out.json.
  3. Ensure the value is non-empty and not just whitespace.
  4. Run with --help to confirm the required flag.

Example fix

# before
node benchmark-large-repo.mjs myrepo
# after
node benchmark-large-repo.mjs myrepo --output reports/out.json
Defensive patterns

Strategy: validation

Validate before calling

const hasOutput = argv.some(a => a === '--output' || a === '-o' || a.startsWith('--output='));
if (!hasOutput) { /* 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: Omitting --output entirely; passing --output= (empty value); passing --output followed by only whitespace.

Common situations: Forgetting the required output flag; assuming a default output location exists; a template script that left the output blank.

Related errors


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