{"record":{"id":"2345eeca250341b1","repo":"affaan-m/ECC","slug":"command-args-join-failed-result-erro-2345ee","errorCode":null,"errorMessage":"${command} ${args.join(' ')} failed: ${result.error.message}","messagePattern":"(.+?) (.+?) failed: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"scripts/lib/github-discussions.js","lineNumber":27,"sourceCode":"\nfunction splitRepo(repo) {\n  const [owner, name] = String(repo || '').split('/');\n  if (!owner || !name) {\n    throw new Error(`Invalid repo: ${repo}`);\n  }\n  return { owner, name };\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":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/affaan-m/ECC/blob/01e15490f04e29cfefe3896951f43db46994d8ee/scripts/lib/github-discussions.js#L9-L45","documentation":"Thrown by runCommand() in scripts/lib/github-discussions.js when spawnSync sets result.error (the child process could not be spawned at all). This is distinct from a non-zero exit: it means the binary was not found, the call was killed, or Node failed to fork.","triggerScenarios":"runCommand(command, args, options) where spawnSync returns { error: Error(...) }. Typical causes: ENOENT because 'gh' (or process.execPath when ECC_GH_SHIM is set) is not on PATH; EACCES on the executable; EMFILE too many open files; signal kill.","commonSituations":"gh CLI is not installed or not on PATH in the current shell; ECC_GH_SHIM points to a missing shim file; running inside a container without the gh binary; CI image lacks gh; PATH was scrubbed when env was overridden.","solutions":["Verify the binary exists: which gh || command -v gh. Install GitHub CLI (https://cli.github.com) if missing.","If using ECC_GH_SHIM, confirm the shim path exists and is executable: ls -l \"$ECC_GH_SHIM\".","Ensure PATH is propagated: pass env: { ...process.env, PATH: process.env.PATH } to runCommand.","In CI, add the gh install step before invoking the coordination script."],"exampleFix":"// before\nconst stdout = runCommand('gh', ['auth', 'status'], { env: scrubbedEnv });\n\n// after\nconst { existsSync } = require('fs');\nif (!existsSync(process.env.ECC_GH_SHIM || '/usr/bin/gh') && !process.env.PATH.split(':').some(p => existsSync(`${p}/gh`))) {\n  throw new Error('gh CLI not found on PATH');\n}\nconst stdout = runCommand('gh', ['auth', 'status'], { env: { ...process.env } });","handlingStrategy":"validation","validationCode":"const { existsSync } = require('fs');\nfunction ghAvailable() {\n  if (process.env.ECC_GH_SHIM) return existsSync(process.env.ECC_GH_SHIM);\n  return process.env.PATH.split(':').some(p => existsSync(`${p}/gh`));\n}\nif (!ghAvailable()) {\n  throw new Error('gh CLI not found; install from https://cli.github.com');\n}","typeGuard":null,"tryCatchPattern":"try {\n  return runCommand('gh', args, opts);\n} catch (err) {\n  if (/ENOENT|failed:/.test(err.message) && !ghAvailable()) {\n    throw new Error('gh CLI missing on PATH — install https://cli.github.com');\n  }\n  throw err;\n}","preventionTips":["Pin gh CLI in CI images and document the minimum version.","When using ECC_GH_SHIM, validate the path exists before spawning.","Always pass env: { ...process.env } so PATH propagates."],"tags":["process","spawn","github","environment"],"backgroundTag":null,"analyzedSha":"01e15490f04e29cfefe3896951f43db46994d8ee","analyzedAt":"2026-08-13T00:31:08.655Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}