{"record":{"id":"9b24bea9f6a78deb","repo":"affaan-m/ECC","slug":"legacy-codex-sync-cannot-be-combined-with-targ","errorCode":null,"errorMessage":"--legacy-codex-sync cannot be combined with --target","messagePattern":"--legacy-codex-sync cannot be combined with --target","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/uninstall.js","lineNumber":150,"sourceCode":"  }\n  return options.dryRun || dryRunEnv === '1';\n}\n\nfunction includesCodexTarget(targets) {\n  return targets.length === 0 || targets.includes('codex');\n}\n\nasync function main() {\n  try {\n    const options = parseArgs(process.argv);\n    if (options.help) {\n      showHelp(0);\n    }\n\n    const dryRun = isDryRun(options);\n\n    if (options.legacyCodexSync && options.targets.length > 0) {\n      throw new Error('--legacy-codex-sync cannot be combined with --target');\n    }\n\n    let result;\n    let mode = 'install-state';\n\n    if (options.legacyCodexSync) {\n      result = uninstallLegacyCodexSync({\n        codexHome: codexHomePath(),\n        dryRun,\n      });\n      mode = 'legacy-codex-sync';\n    } else {\n      result = uninstallInstalledStates({\n        homeDir: process.env.HOME || os.homedir(),\n        env: process.env,\n        projectRoot: process.cwd(),\n        targets: options.targets,\n        dryRun,","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/uninstall.js#L132-L168","documentation":"The uninstall script enforces that --legacy-codex-sync (a full legacy-state sync mode) and --target (selective component removal) are mutually exclusive operation modes. Throwing here prevents an ambiguous uninstall where the script could not decide whether to sync everything or remove only selected targets.","triggerScenarios":"Running `node scripts/uninstall.js --legacy-codex-sync --target <name>` (or any --targets value) so that options.legacyCodexSync is truthy while options.targets.length > 0 when main() validates the parsed options.","commonSituations":"Users upgrading from older install workflows combine a remembered --legacy-codex-sync flag with newer --target flags copied from docs or shell history; shell aliases or CI scripts accumulating flags from different eras of the tool.","solutions":["Remove either --legacy-codex-sync or all --target flags from the command — run one mode at a time","If you want selective removal, drop --legacy-codex-sync and list only the targets","If you want a full legacy sync, drop all --target flags","Check the script's help output (it runs showHelp on bad input paths) for current flag combinations"],"exampleFix":"// before\nnode scripts/uninstall.js --legacy-codex-sync --target commands\n// after\nnode scripts/uninstall.js --target commands","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args.includes('--legacy-codex-sync') && (args.includes('--target') || args.includes('--targets'))) {\n  throw new Error('--legacy-codex-sync cannot be combined with --target');\n}","typeGuard":"function isExclusiveCombo(options) {\n  return typeof options.legacyCodexSync === 'boolean' &&\n    Array.isArray(options.targets) &&\n    options.targets.length > 0 &&\n    options.legacyCodexSync === true;\n}","tryCatchPattern":"try {\n  await main(process.argv.slice(2));\n} catch (err) {\n  if (err.message.includes('cannot be combined')) {\n    console.error('Pick either --legacy-codex-sync OR --target flags, not both.');\n    process.exit(2);\n  }\n  throw err;\n}","preventionTips":["Run one uninstall mode per invocation; chain separate commands if both are needed","Keep flag recipes in scripts updated when migrating away from legacy workflows","Add a shell alias per mode instead of accumulating flags","Check --help before combining unfamiliar flags"],"tags":["cli","flags","mutually-exclusive"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"8321021c54d670126ce3b2969d5deb880b4b0c2a","analyzedAt":"2026-09-16T10:08:13.343Z","contentChangedAt":"2026-09-16T10:08:13.343Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}