affaan-m/ECC · error
failed
Error message
${command} ${args.join(' ')} failed: ${result.error.message} What it means
runCommand in scripts/platform-audit.js spawns a child process with spawnSync and throws this error when spawn itself reports result.error — i.e. the process could not be spawned, was killed, or failed before producing a status code. The message embeds the failing command line and Node's underlying error message (e.g. ENOENT). It is distinct from a non-zero exit, which produces the sibling error at line 238.
Solutions
- Install the missing binary (e.g. `gh`) or fix its PATH so it resolves
- Verify the command is executable (chmod +x, correct absolute path)
- Add a preflight check like `command -v gh` before running the audit
- Read the embedded result.error.message (ENOENT/EACCES/ETIMEDOUT) to identify the spawn cause
Example fix
// before
const stdout = runCommand('gh', ['pr', 'list']);
// after
if (!commandExists('gh')) {
throw new Error('gh CLI not found; install it or extend PATH');
}
const stdout = runCommand('gh', ['pr', 'list']); Defensive patterns
Strategy: try-catch
Validate before calling
const { execFileSync } = require('child_process');
function commandExists(cmd) {
try { execFileSync(cmd, ['--version'], { stdio: 'ignore' }); return true; }
catch (e) { return e.code !== 'ENOENT'; }
} Type guard
function isSpawnError(result) {
return result != null && typeof result === 'object' && 'error' in result && result.error instanceof Error;
} Try / catch
try {
const out = runCommand('gh', ['pr', 'list']);
} catch (e) {
if (e.message.includes('failed:') && /ENOENT|EACCES/.test(e.message)) {
console.error('Required CLI not installed or not executable:', e.message);
process.exitCode = 127;
} else throw e;
} Prevention
- Verify required binaries (gh, git) exist in the runtime environment
- Pin tool installation in CI images before running audits
- Check PATH inside spawned contexts matches your shell's PATH
- Handle ENOENT vs EACCES differently — install vs chmod
When it happens
Trigger: Calling runCommand with a command binary that does not exist on PATH (ENOENT), lacks execute permission (EACCES), or is killed by a signal; any caller such as runGhJson invoking a missing `gh` binary.
Common situations: `gh` CLI not installed in the environment running the audit; CI containers missing the tool; PATH differences between local shells and spawned environments; Windows without a shell wrapper.
Related errors
AI-assisted analysis of affaan-m/ECC@8321021c54 (2026-09-16).
Data as JSON: /api/errors/959b35729f465222.
Report an issue: GitHub.
Appendix: source
Thrown at scripts/platform-audit.js:234
}
function normalizeRelativePrefix(value) {
return String(value || '')
.replace(/\\/g, '/')
.replace(/^\.\/+/, '')
.replace(/\/+$/, '') + (String(value || '').endsWith('/') ? '/' : '');
}
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 8321021c54)