{"record":{"id":"272c493e3ed8e9db","repo":"affaan-m/ECC","slug":"setup-failed","errorCode":"SETUP_FAILED","errorMessage":"SETUP_FAILED: ${error.message}","messagePattern":"SETUP_FAILED: (.+?)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"scripts/setup.js","lineNumber":322,"sourceCode":"    return;\n  }\n  process.stdout.write(`\\nECC ${result.action} ${result.pluginId} at ${result.scope} scope.\\n`);\n  if (result.sourceScope) {\n    process.stdout.write(`Previous scope: ${result.sourceScope}\\n`);\n  }\n  process.stdout.write(`Hook preference: ${result.hooks}\\n`);\n  if (result.restartRequired) {\n    process.stdout.write('Restart Claude Code or run /reload-plugins to load the updated plugin.\\n');\n  }\n}\n\nfunction printError(error, json) {\n  if (json) {\n    const payload = error instanceof ClaudeSetupError\n      ? error.toJSON()\n      : {\n        error: {\n          code: 'SETUP_FAILED',\n          message: error.message,\n          phase: 'cli',\n          observedScopes: [],\n          recovery: [],\n        },\n      };\n    process.stderr.write(`${JSON.stringify(payload, null, 2)}\\n`);\n    return;\n  }\n  process.stderr.write(`Error: ${error.message}\\n`);\n}\n\nfunction isInteractiveCancellation(error) {\n  return Boolean(error && (\n    error.code === 'ABORT_ERR'\n    || /aborted with ctrl\\+d|readline was closed/i.test(error.message || '')\n  ));\n}","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/setup.js#L304-L340","documentation":"printError in the setup CLI is the last-resort error reporter. When the thrown error is not a ClaudeSetupError (which carries its own code/phase/recovery), it wraps the raw message in a generic SETUP_FAILED payload with phase 'cli' and empty recovery hints (or prints it plainly in non-JSON mode). It signals the setup script aborted for a reason the CLI did not classify.","triggerScenarios":"scripts/setup.js throws a plain Error during main() — e.g. failed network fetch of Claude assets, file-system permission errors when writing config, unparseable CLI flags — anything not wrapped as ClaudeSetupError before reaching printError.","commonSituations":"No network access while setup downloads prerequisites; running setup in a directory without write permissions; corrupted existing config file that setup chokes on; invoking with malformed arguments that skip earlier validation.","solutions":["Read the inner error.message in the SETUP_FAILED payload — it names the real cause (network, permissions, parse failure)","Fix the underlying cause (restore network, fix directory permissions, repair/remove the corrupt config) and re-run setup","Run with JSON output to get the structured payload (code, phase, observedScopes) for easier diagnosis","If a specific phase keeps failing, look for a ClaudeSetupError-scoped recovery for that phase in the setup docs"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight checks before setup.js main():\n// network reachability, write access to target dirs, existing config JSON.parse","typeGuard":null,"tryCatchPattern":"try { runSetup(); } catch (e) {\n  const payload = e instanceof ClaudeSetupError ? e.toJSON() : { error: { code: 'SETUP_FAILED', message: e.message } };\n  console.error(JSON.stringify(payload));\n  // branch on the inner message: network vs permissions vs parse\n}","preventionTips":["Check network and disk-write permissions before running setup","Back up and validate any existing config file the setup script will read or rewrite","Wrap known-failure points in ClaudeSetupError so phase and recovery info survive to printError"],"tags":["cli","setup","unclassified-error"],"backgroundTag":"setup-failed","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"}