affaan-m/ECC · error · Error

Unknown argument: ${arg}

Error message

Unknown argument: ${arg}

What it means

Thrown by repair.js parseArgs when an argument token matches none of the accepted flags: --target <id>, --dry-run, --json, --help/-h. repair has a small fixed surface and rejects anything else rather than silently ignoring it.

Source

Thrown at scripts/repair.js:39

    dryRun: false,
    json: false,
    help: false,
  };

  for (let index = 0; index < args.length; index += 1) {
    const arg = args[index];

    if (arg === '--target') {
      parsed.targets.push(args[index + 1] || null);
      index += 1;
    } else if (arg === '--dry-run') {
      parsed.dryRun = true;
    } else if (arg === '--json') {
      parsed.json = true;
    } else if (arg === '--help' || arg === '-h') {
      parsed.help = true;
    } else {
      throw new Error(`Unknown argument: ${arg}`);
    }
  }

  return parsed;
}

function printHuman(result) {
  if (result.results.length === 0) {
    console.log('No ECC install-state files found for the current home/project context.');
    return;
  }

  console.log('Repair summary:\n');
  for (const entry of result.results) {
    console.log(`- ${entry.adapter.id}`);
    console.log(`  Status: ${entry.status.toUpperCase()}`);
    console.log(`  Install-state: ${entry.installStatePath}`);

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Run `node scripts/repair.js --help` to confirm the flag set.
  2. Fix the typo (e.g. `--dry-run` not `--dryrun`).
  3. Repeat --target once per target id rather than comma-separating.
  4. Remove flags that belong to other scripts.

Example fix

# before
node scripts/repair.js --targets foo,bar --dryrun
# after
node scripts/repair.js --target foo --target bar --dry-run
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED = new Set(['--target', '--dry-run', '--json', '--help', '-h']);
const bad = process.argv.slice(2).filter(a => a.startsWith('--') && !ALLOWED.has(a));
if (bad.length) { console.error('Unknown flag(s) for repair.js:', bad.join(' ')); process.exit(2); }

Try / catch

try { parseArgs(process.argv); } catch (err) { console.error(err.message); process.exit(2); }

Prevention

When it happens

Trigger: Passing a flag like --scope or --fix that belongs to setup.js; a typo such as `--dryrun` (missing hyphen); an unexpected positional argument.

Common situations: Confusing repair.js flags with setup.js flags (both are ECC scripts); using long-form variants the parser does not support; stale flags from an older ECC version.

Related errors


AI-assisted analysis of affaan-m/ECC@01e15490f0 (2026-08-13). Data as JSON: /api/errors/b388de86682fb30d. Report an issue: GitHub.