chenglou/pretext · error · Error
Command failed (${result.exitCode}): ${cmd.join(' ')}
Error message
Command failed (${result.exitCode}): ${cmd.join(' ')} What it means
run() is the shared subprocess wrapper in package-smoke-test.ts. When allowFailure is not set and the spawned command exits non-zero, it throws this generic wrapper with the exit code and the command line. It guards every external process the smoke test shells out to (npm pack, npm install, node, tsc).
Source
Thrown at scripts/package-smoke-test.ts:186
cmd: string[],
options: {
cwd: string
stdout: 'inherit' | 'pipe'
stderr: 'inherit' | 'pipe'
allowFailure?: boolean
},
): { exitCode: number, stdout: string, stderr: string } {
const result = Bun.spawnSync(cmd, {
cwd: options.cwd,
stdout: options.stdout,
stderr: options.stderr,
})
const stdout = options.stdout === 'pipe' ? new TextDecoder().decode(result.stdout) : ''
const stderr = options.stderr === 'pipe' ? new TextDecoder().decode(result.stderr) : ''
if (!options.allowFailure && result.exitCode !== 0) {
throw new Error(`Command failed (${result.exitCode}): ${cmd.join(' ')}`)
}
return {
exitCode: result.exitCode,
stdout,
stderr,
}
}
View on GitHub (pinned to ac49b09b7d)
Solutions
- Identify which command failed from the `cmd.join(' ')` portion of the message.
- Reproduce that exact command manually to see its real output (the wrapper inherits stdout/stderr for non-pipe calls, so check the log above the error).
- For npm pack: build dist/ first. For npm install: check network/registry. For node/tsc: inspect the consumer error and trace it back to the package export or type surface.
Defensive patterns
Strategy: try-catch
Try / catch
try {
run(['npm', 'pack', '--pack-destination', packDir], { cwd: root, stdout: 'inherit', stderr: 'inherit' })
} catch (e) {
const msg = e instanceof Error ? e.message : String(e)
if (msg.startsWith('Command failed')) {
console.error('Subprocess failed during smoke test. Build dist/ first and check network/registry.')
process.exit(1)
}
throw e
} Prevention
- Build dist/ before running the smoke test so npm pack has files to pack.
- Run each external command (npm pack, npm install, node, tsc) manually first when debugging to see real output.
When it happens
Trigger: `npm pack` fails (missing files/build), `npm install` fails (registry/network, bad tarball), `node index.js` fails (consumer runtime error), or the positive `tsc` compile fails (consumer type error against valid usage).
Common situations: Smoke test run on a clean checkout without dist/ built, network/registry problems during install, or a real regression that breaks either the JS ESM consumer or the valid-TS consumer.
Related errors
- Expected exactly one tarball in ${packDir}, found ${tarballs
- corpus-check exited with status ${result.status ?? 'unknown'
- Expected TypeScript consumer misuse to fail, but it compiled
- Unexpected TypeScript consumer error output: ${combinedOutpu
AI-assisted analysis of chenglou/pretext@ac49b09b7d (2026-08-12).
Data as JSON: /api/errors/015782b0f6fe90da.
Report an issue: GitHub.