{"record":{"id":"e8a4ae1fab0613bb","repo":"affaan-m/ECC","slug":"command-args-join-failed-erroroutput","errorCode":null,"errorMessage":"${command} ${args.join(' ')} failed${errorOutput ? `: ${errorOutput}` : ''}","messagePattern":"(.+?) (.+?) failed(.+?)` : ''\\}","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/auto-update.js","lineNumber":178,"sourceCode":"\n  return normalized;\n}\n\nfunction runExternalCommand(command, args, options = {}) {\n  const result = spawnSync(command, args, {\n    cwd: options.cwd,\n    env: options.env || process.env,\n    encoding: 'utf8',\n    maxBuffer: 10 * 1024 * 1024\n  });\n\n  if (result.error) {\n    throw result.error;\n  }\n\n  if (typeof result.status === 'number' && result.status !== 0) {\n    const errorOutput = (result.stderr || result.stdout || '').trim();\n    throw new Error(`${command} ${args.join(' ')} failed${errorOutput ? `: ${errorOutput}` : ''}`);\n  }\n\n  return result;\n}\n\nfunction legacyMigrationWarning(record) {\n  if (record.legacyLayout === 'opencode') {\n    return 'Found only a legacy OpenCode ~/.opencode install-state. Run the OpenCode installer once to migrate it to the configured OpenCode directory before auto-updating.';\n  }\n  return 'Found only a legacy Antigravity .agent install-state. Run the Antigravity installer once to migrate it to .agents before auto-updating.';\n}\n\nfunction runAutoUpdate(options = {}, dependencies = {}) {\n  const discover = dependencies.discoverInstalledStates || discoverInstalledStates;\n  const execute = dependencies.runExternalCommand || runExternalCommand;\n  const homeDir = options.homeDir || process.env.HOME || os.homedir();\n  const projectRoot = options.projectRoot || process.cwd();\n  const requestedRepoRoot = options.repoRoot ? validateRepoRoot(options.repoRoot) : null;","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/affaan-m/ECC/blob/8321021c54d670126ce3b2969d5deb880b4b0c2a/scripts/auto-update.js#L160-L196","documentation":"scripts/auto-update.js's runExternalCommand wraps child_process execution. When a spawned CLI process exits with a nonzero status, the wrapper throws an Error whose message embeds the command line and the trimmed stderr (or stdout) output, so the underlying tool's own diagnostic is preserved.","triggerScenarios":"Any external command spawned via runExternalCommand (e.g. git, npm) exits with result.status !== 0; result.error is null but the process reported failure through its exit code.","commonSituations":"git fetch/pull failing due to network issues or auth prompts, npm update failing because of lockfile conflicts or registry outages, running auto-update outside a git checkout so git commands fail.","solutions":["Read the stderr excerpt appended to the message — it is the child tool's own error, fix that root cause","Re-run the failing command manually (command + args from the message) to reproduce and see full output","Check network/auth for git or npm operations (credentials, VPN, registry status)","Ensure the working directory is a valid git repo before running auto-update"],"exampleFix":"// before (from a shell)\nnode scripts/auto-update.js\n// Error: git pull failed: fatal: not a git repository...\n// after\n# run from the repo root, or pass the repo root explicitly\ncd /path/to/ECC && node scripts/auto-update.js","handlingStrategy":"try-catch","validationCode":"const result = cp.spawnSync(cmd, args, { encoding: 'utf8' });\nif (result.status !== 0) {\n  console.error(`Skipping update: ${cmd} exited ${result.status}: ${result.stderr}`);\n  return;\n}","typeGuard":"function isSuccessfulSpawn(result) {\n  return result.error == null && result.status === 0;\n}","tryCatchPattern":"try {\n  runExternalCommand('git', ['pull']);\n} catch (err) {\n  console.error('auto-update command failed:', err.message);\n  // inspect embedded stderr excerpt for the child tool's root cause\n}","preventionTips":["Always run auto-update from a valid git checkout","Check network/auth for the underlying tool before automating it","Log full stdout/stderr, not just the wrapped message","Prefer explicit repo-root over inference to reduce failure modes"],"tags":["child-process","cli","subprocess-failure"],"backgroundTag":"git-command-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"}