affaan-m/ECC · error · Error

Unknown argument

Error message

Unknown argument: ${arg}

What it means

parseArgs in scripts/uninstall.js accepts a fixed set of flags (e.g. --json, --legacy-codex-sync, --help/-h) and throws "Unknown argument: <arg>" for any token that matches none of them. Because uninstall is destructive, strict flag validation prevents unintended or mistyped options from being silently ignored.

Solutions

  1. Run `node scripts/uninstall.js --help` to list accepted flags.
  2. Correct the typo to the supported spelling (watch hyphen placement, e.g. --legacy-codex-sync).
  3. Remove flags that belong to other scripts before running uninstall.

Example fix

// before
node scripts/uninstall.js --dryrun
// after
node scripts/uninstall.js --help   # then use a supported flag, e.g. --json
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED = new Set(['--json', '--legacy-codex-sync', '--help', '-h']);
const unknown = process.argv.slice(2).filter(a => a.startsWith('--') && !SUPPORTED.has(a));
if (unknown.length) console.error('Unsupported flags for uninstall:', unknown);

Try / catch

try {
  runUninstall(argv);
} catch (e) {
  if (e.message.startsWith('Unknown argument')) {
    console.error(`${e.message}. Run 'node scripts/uninstall.js --help' before destructive operations.`);
    process.exitCode = 1;
  } else throw e;
}

Prevention

When it happens

Trigger: Running `node scripts/uninstall.js --dryrun` (typo, if --dry-run is the supported spelling) or passing flags from other scripts like --markdown to uninstall.js.

Common situations: Typos on a destructive command; carrying flags over from skills-health.js or status.js command lines; outdated shell history entries after the script's flag set changed.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16). Data as JSON: /api/errors/052fecf802eca3b8. Report an issue: GitHub.

Appendix: source

Thrown at scripts/uninstall.js:51

    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 === '--legacy-codex-sync') {
      parsed.legacyCodexSync = 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;
  }

  // Dry-run output must be phrased as a preview so it can never be mistaken
  // for a completed uninstall (#2952).
  console.log(`Uninstall summary${result.dryRun ? ' (dry run; nothing was removed)' : ''}:\n`);
  for (const entry of result.results) {
    console.log(`- ${entry.adapter.id}`);
    const statusLabel = result.dryRun && entry.status === 'planned'

View on GitHub (pinned to 8321021c54)