affaan-m/ECC · error · Error

Invalid --scope value: ${options.scope}

Error message

Invalid --scope value: ${options.scope}

What it means

Thrown by setup.js when --scope is provided but is not in VALID_SCOPES ({user, project, local}). Scope determines where the plugin is installed, so an unknown scope is rejected to prevent writing to an unintended location.

Source

Thrown at scripts/setup.js:107

      options.yes = true;
    } else if (argument === '--dry-run') {
      options.dryRun = true;
    } else if (argument === '--move-scope') {
      options.moveScope = true;
    } else if (argument === '--json') {
      options.json = true;
    } else if (argument === '--help' || argument === '-h') {
      options.help = true;
    } else {
      throw new Error(`Unknown argument: ${argument}`);
    }
  }

  if (options.mode !== undefined && options.mode !== MODE) {
    throw new Error(`Invalid setup mode: ${options.mode}. This command currently supports ${MODE}.`);
  }
  if (options.scope !== undefined && !VALID_SCOPES.has(options.scope)) {
    throw new Error(`Invalid --scope value: ${options.scope}`);
  }
  if (options.hooks !== undefined && !VALID_HOOK_MODES.has(options.hooks)) {
    throw new Error(`Invalid --hooks value: ${options.hooks}`);
  }
  if (options.moveScope && options.scope === undefined) {
    throw new Error('--move-scope requires an explicit --scope destination.');
  }
  return options;
}

function questionWithCancellation(terminal, prompt) {
  return new Promise((resolve, reject) => {
    let settled = false;
    const finish = callback => value => {
      if (settled) return;
      settled = true;
      terminal.removeListener('close', onClose);
      callback(value);

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Choose one of: user, project, or local.
  2. Omit --scope to let the interactive prompt choose.
  3. Remember --move-scope also requires a valid --scope destination.

Example fix

# before
node scripts/setup.js --scope global --yes
# after
node scripts/setup.js --scope user --yes
Defensive patterns

Strategy: validation

Validate before calling

const SCOPES = new Set(['user', 'project', 'local']);
const scope = (process.argv.find(a => a.startsWith('--scope')) || '').split('=')[1];
if (scope !== undefined && !SCOPES.has(scope)) { console.error(`Invalid scope: ${scope}`); process.exit(2); }

Type guard

function isValidScope(v) { return v === 'user' || v === 'project' || v === 'local'; }

Try / catch

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

Prevention

When it happens

Trigger: Passing `--scope global`, `--scope system`, or any value outside user/project/local.

Common situations: Assuming a 'global' scope exists; typos like `--scope usr`; mixing up scope with mode; copy-pasting a scope from a different plugin manager.

Related errors


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