{"record":{"id":"959b35729f465222","repo":"affaan-m/ECC","slug":"command-args-join-failed-result-erro-959b35","errorCode":null,"errorMessage":"${command} ${args.join(' ')} failed: ${result.error.message}","messagePattern":"(.+?) (.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/platform-audit.js","lineNumber":234,"sourceCode":"}\n\nfunction normalizeRelativePrefix(value) {\n  return String(value || '')\n    .replace(/\\\\/g, '/')\n    .replace(/^\\.\\/+/, '')\n    .replace(/\\/+$/, '') + (String(value || '').endsWith('/') ? '/' : '');\n}\n\nfunction runCommand(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 new Error(`${command} ${args.join(' ')} failed: ${result.error.message}`);\n  }\n\n  if (result.status !== 0) {\n    throw new Error(`${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`);\n  }\n\n  return result.stdout || '';\n}\n\nfunction runGhJson(args, options = {}) {\n  const shimPath = process.env.ECC_GH_SHIM;\n  const command = shimPath ? process.execPath : 'gh';\n  const commandArgs = shimPath ? [shimPath, ...args] : args;\n  const env = { ...process.env };\n\n  if (!options.useEnvGithubToken) {\n    delete env.GITHUB_TOKEN;\n  }","sourceCodeStart":216,"sourceCodeEnd":252,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/platform-audit.js#L216-L252","documentation":"Thrown by runCommand in platform-audit when `spawnSync` returns a non-null `error` — meaning the child process could not be spawned at all (command not found, permission denied, EACCES/ENOENT). This is distinct from a non-zero exit status; `result.error` is set by Node when the binary itself is unreachable. The message interpolates the raw Node error string for diagnosis.","triggerScenarios":"Calling `git`/`gh`/`node` when not on PATH (ENOENT); the binary exists but is not executable (EACCES); a shim path (ECC_GH_SHIM) points to a missing file; spawning on an OS where the command name differs.","commonSituations":"CI image missing gh; local install where `gh` is absent but `--skip-github` was not passed; ECC_GH_SHIM env var stale after a move; PATH not propagated into the spawned env.","solutions":["Verify the binary is installed and on PATH: `which gh git node`.","Install missing tool (e.g. `gh auth login` after installing GitHub CLI), or pass `--skip-github` to bypass gh.","If using ECC_GH_SHIM, confirm the shim file exists and is executable; unset it to fall back to real `gh`.","Ensure the parent process env (used as default) includes the directory containing the binary."],"exampleFix":"# before — gh not installed\nnode scripts/platform-audit.js\n# after — install gh, or skip github checks\nnode scripts/platform-audit.js --skip-github","handlingStrategy":"validation","validationCode":"const { spawnSync } = require('child_process');\nfunction binaryAvailable(name) {\n  const r = process.platform === 'win32'\n    ? spawnSync('where', [name], { encoding: 'utf8' })\n    : spawnSync('command', ['-v', name], { encoding: 'utf8', shell: true });\n  return r.status === 0 && (r.stdout || '').trim().length > 0;\n}","typeGuard":"function isSpawnError(result) {\n  return result && Object.prototype.hasOwnProperty.call(result, 'error') && result.error !== null;\n}","tryCatchPattern":"try {\n  runCommand('gh', ['repo','view','--json','name'], { env });\n} catch (err) {\n  if (/failed: .*ENOENT/.test(err.message)) {\n    console.error('gh not found on PATH. Install GitHub CLI or pass --skip-github.');\n    process.exit(127);\n  }\n  throw err;\n}","preventionTips":["Ensure git, gh, node are installed and on PATH in CI and locally.","Validate ECC_GH_SHIM points to an existing executable file.","Pass --skip-github in environments without gh to avoid this path."],"tags":["spawn","platform-audit","environment","enoent"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}