affaan-m/ECC · critical · Error

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

Error message

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

What it means

Thrown by runCommand when spawnSync returns a non-null result.error, meaning the child process could not be spawned at all. This is distinct from a non-zero exit (which is error 136): here the binary was not found, was not executable, or the spawn itself failed (ENOENT, EACCES, E2BIG). The wrapped error.message identifies the OS-level cause.

Source

Thrown at scripts/lib/github-coordination/gh-api.js:45

    return String(label.name || label.label || '').trim();
  }
  return '';
}

function normalizeLabels(labels) {
  return Array.from(new Set((Array.isArray(labels) ? labels : []).map(normalizeLabelValue).filter(Boolean))).sort();
}

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 || '';
}

// ECC_GH_SHIM creates a trust boundary: when set, shimPath replaces the real
// `gh` binary and command/commandArgs execute an arbitrary script via
// process.execPath. This variable MUST only be set in trusted, isolated test
// environments (e.g., a test's own temp directory). Never set ECC_GH_SHIM in
// production — doing so allows arbitrary script execution under the caller's
// privileges.
function runGh(args, options = {}) {
  const shimPath = process.env.ECC_GH_SHIM;
  const command = shimPath ? process.execPath : 'gh';

View on GitHub (pinned to 01e15490f0)

Solutions

  1. Install the GitHub CLI (gh) and ensure it is on PATH: run `gh --version` in the same shell/env as the Node process.
  2. Verify process.env.PATH inside the Node process includes the directory containing gh.
  3. If using ECC_GH_SHIM for tests, confirm the shim path exists and is executable.
  4. Check result.error.code (ENOENT vs EACCES) to distinguish missing-binary from permission issues.

Example fix

// before
runGh(['issue', 'view', String(n)]);

// after — verify gh availability with a clear message
const { spawnSync } = require('child_process');
const probe = spawnSync('gh', ['--version'], { encoding: 'utf8' });
if (probe.error) {
  throw new Error(`GitHub CLI (gh) not available: ${probe.error.message}. Install from https://cli.github.com`);
}
runGh(['issue', 'view', String(n)]);
Defensive patterns

Strategy: validation

Validate before calling

const probe = spawnSync('gh', ['--version'], { encoding: 'utf8' });
if (probe.error) {
  throw new Error(`gh not available: ${probe.error.message}. Install from https://cli.github.com`);
}

Type guard

function ghAvailable() {
  const { error } = spawnSync('gh', ['--version'], { encoding: 'utf8' });
  return !error;
}

Try / catch

try {
  runGh(args);
} catch (e) {
  if (/failed: ENOENT/.test(e.message)) { throw new Error('Install the GitHub CLI (gh) and ensure it is on PATH'); }
  throw e;
}

Prevention

When it happens

Trigger: gh is not installed or not on PATH (ENOENT); the binary path lacks execute permission (EACCES); ECC_GH_SHIM points at a non-existent path; the args/env are too large (E2BIG).

Common situations: Fresh CI runner without gh installed; local dev machine missing gh; PATH not propagated to the Node process; shim path configured wrong in tests.

Related errors


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