Mintplex-Labs/anything-llm · error · Error
${text} Command exited with code ${realExitCode}
Error message
${text}
Command exited with code ${realExitCode} What it means
Thrown by visible-bash when the spawned command completes with realExitCode that is neither 0 nor null. realExitCode is read from a captured exit-code file (falling back to the spawn exit code). The thrown message includes the truncated stdout+stderr ('text'), so the failure cause is visible inline. This is the normal non-zero-exit path.
Source
Thrown at open-computer/services/extensions/visible-bash.ts:205
throw new Error(
output
? `${truncateOutput(output)}\n\nCommand aborted`
: "Command aborted"
);
}
if (timedOut) {
throw new Error(
output
? `${truncateOutput(output)}\n\nCommand timed out after ${timeout} seconds`
: `Command timed out after ${timeout} seconds`
);
}
const text = truncateOutput(output) || "(no output)";
if (realExitCode !== 0 && realExitCode !== null) {
throw new Error(`${text}\n\nCommand exited with code ${realExitCode}`);
}
return { content: [{ type: "text", text }], details: {} };
} finally {
cleanup();
}
},
});
}
function truncateOutput(raw: string): string {
if (raw.length <= MAX_OUTPUT_BYTES && raw.split("\n").length <= MAX_OUTPUT_LINES) {
return raw;
}
let text = raw;
if (text.length > MAX_OUTPUT_BYTES) {
text = text.slice(-MAX_OUTPUT_BYTES);View on GitHub (pinned to 526360e320)
Solutions
- Read the captured 'text' in the message — it contains the command's stderr/stdout explaining the failure.
- Fix the underlying command failure (resolve the type/test/build error) rather than suppressing.
- If a non-zero exit is expected/acceptable, wrap the command with `|| true` or check exit code explicitly.
- Verify the spawn environment PATH has the required binaries.
Example fix
// before — non-zero exit throws
bash({ command: "npm test" });
// after — tolerate expected non-zero
bash({ command: "npm test || true" }); Defensive patterns
Strategy: try-catch
Try / catch
try {
const { content } = await bash({ command });
} catch (e) {
// e.message includes the command's truncated stdout/stderr + exit code
if (/exited with code/.test(e.message)) {
reportFailure(e.message);
return;
}
throw e;
} Prevention
- Read the captured text in the error — it contains the failing command's output.
- Fix the underlying command failure rather than suppressing the exit code.
- Append `|| true` only when a non-zero exit is genuinely acceptable.
When it happens
Trigger: Any shell command that exits non-zero: failing tests, type errors, missing binaries (127), permission denied (126), segfault (139), or a command that prints errors then exits 1.
Common situations: tsc/lint failing on the diff; a test suite with a failing assertion; command not found because PATH differs in the spawn environment; permission bits on a script; OOM kill (exit code 137).
Related errors
AI-assisted analysis of Mintplex-Labs/anything-llm@526360e320 (2026-08-13).
Data as JSON: /api/errors/0adb0a749c6358fe.
Report an issue: GitHub.