affaan-m/ECC · error · Error

${command} ${args.join(' ')} failed: ${result.error.message}

Error message

${command} ${args.join(' ')} failed: ${result.error.message}

What it means

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.

Source

Thrown at scripts/lib/github-discussions.js:27

function splitRepo(repo) {
  const [owner, name] = String(repo || '').split('/');
  if (!owner || !name) {
    throw new Error(`Invalid repo: ${repo}`);
  }
  return { owner, name };
}

function runCommand(command, args, options = {}) {
  const result = spawnSync(command, args, {
    cwd: options.cwd,
    env: options.env || process.env,
    encoding: 'utf8',
    maxBuffer: 10 * 1024 * 1024,
  });

  if (result.error) {
    throw new Error(`${command} ${args.join(' ')} failed: ${result.error.message}`);
  }

  if (result.status !== 0) {
    throw new Error(`${command} ${args.join(' ')} failed: ${(result.stderr || result.stdout || '').trim()}`);
  }

  return result.stdout || '';
}

function runGhJson(args, options = {}) {
  const shimPath = process.env.ECC_GH_SHIM;
  const command = shimPath ? process.execPath : 'gh';
  const commandArgs = shimPath ? [shimPath, ...args] : args;
  const env = { ...process.env };

  if (!options.useEnvGithubToken) {
    delete env.GITHUB_TOKEN;
  }

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Verify the binary exists: which gh || command -v gh. Install GitHub CLI (https://cli.github.com) if missing.
  2. If using ECC_GH_SHIM, confirm the shim path exists and is executable: ls -l "$ECC_GH_SHIM".
  3. Ensure PATH is propagated: pass env: { ...process.env, PATH: process.env.PATH } to runCommand.
  4. In CI, add the gh install step before invoking the coordination script.

Example fix

// before
const stdout = runCommand('gh', ['auth', 'status'], { env: scrubbedEnv });

// after
const { existsSync } = require('fs');
if (!existsSync(process.env.ECC_GH_SHIM || '/usr/bin/gh') && !process.env.PATH.split(':').some(p => existsSync(`${p}/gh`))) {
  throw new Error('gh CLI not found on PATH');
}
const stdout = runCommand('gh', ['auth', 'status'], { env: { ...process.env } });
Defensive patterns

Strategy: validation

Validate before calling

const { existsSync } = require('fs');
function ghAvailable() {
  if (process.env.ECC_GH_SHIM) return existsSync(process.env.ECC_GH_SHIM);
  return process.env.PATH.split(':').some(p => existsSync(`${p}/gh`));
}
if (!ghAvailable()) {
  throw new Error('gh CLI not found; install from https://cli.github.com');
}

Try / catch

try {
  return runCommand('gh', args, opts);
} catch (err) {
  if (/ENOENT|failed:/.test(err.message) && !ghAvailable()) {
    throw new Error('gh CLI missing on PATH — install https://cli.github.com');
  }
  throw err;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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