affaan-m/ECC · error · Error
begin requires --codex-home and --backup-dir
Error message
begin requires --codex-home and --backup-dir
What it means
main's 'begin' branch throws when either --codex-home or --backup-dir is missing or has no usable value. Legacy sync state must record both the Codex home and the backup location before any migration steps can begin.
Solutions
- Call: legacy-sync-state.js begin --codex-home <dir> --backup-dir <dir>.
- Ensure flag values do not start with '--' or are absent (readFlag returns null then).
- Check the installer script passes both flags.
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at scripts/codex/legacy-sync-state.js:24 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/3a267fd01bc789cf.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/codex/legacy-sync-state.js:24
finalizeLegacySyncState,
recordLegacySyncPath,
rollbackLegacyCodexSync,
} = require('../lib/codex-legacy-sync');
function readFlag(args, name) {
const index = args.indexOf(name);
if (index === -1) return null;
const value = args[index + 1];
if (!value || value.startsWith('--')) return null;
return value;
}
function main(argv = process.argv.slice(2)) {
const command = argv[0];
if (command === 'begin') {
const codexHome = readFlag(argv, '--codex-home');
const backupDir = readFlag(argv, '--backup-dir');
if (!codexHome || !backupDir) throw new Error('begin requires --codex-home and --backup-dir');
process.stdout.write(`${beginLegacySyncState({
codexHome,
backupDir,
previousHooksPath: readFlag(argv, '--previous-hooks-path') || '',
installedHooksPath: readFlag(argv, '--installed-hooks-path'),
})}\n`);
return;
}
if (command === 'record') {
const statePath = readFlag(argv, '--state');
const filePath = readFlag(argv, '--path');
if (!statePath || !filePath) throw new Error('record requires --state and --path');
recordLegacySyncPath({ statePath, filePath });
return;
}
if (command === 'finalize') {
const statePath = readFlag(argv, '--state');
if (!statePath) throw new Error('finalize requires --state');View on GitHub (pinned to 8321021c54)