rohitg00/agentmemory · warning
msg.slice(0, 300) (command stderr/stdout or "unknown error")
Error message
msg.slice(0, 300) (command stderr/stdout or "unknown error")
What it means
This is not a thrown error but the CLI's runCommand() helper reporting a failed subprocess: it runs a command with spawnSync, and on non-zero exit prints `stderr || stdout || "unknown error"` truncated to 300 chars via p.log.warn (optional step, marked skipped) or p.log.error (required step, marked failed). It surfaces whatever the underlying tool (build, doctor, install step) wrote to its streams.
Source
Thrown at src/cli.ts:3145
spinner.start(options.label);
const result = spawnSync(command, commandArgs, {
cwd: options.cwd || process.cwd(),
stdio: "pipe",
encoding: "utf-8",
});
if (result.status === 0) {
spinner.stop(`${options.label} ${pc.green("✓")}`);
return true;
}
const stderr = (result.stderr || "").toString().trim();
const stdout = (result.stdout || "").toString().trim();
const msg = stderr || stdout || "unknown error";
if (options.optional) {
spinner.stop(`${options.label} (skipped)`);
p.log.warn(msg.slice(0, 300));
return false;
}
spinner.stop(`${options.label} ${pc.red("✗")}`);
p.log.error(msg.slice(0, 300));
return false;
}
async function runUpgrade() {
p.intro("agentmemory upgrade");
const cwd = process.cwd();
const hasPackageJson = existsSync(join(cwd, "package.json"));
const hasPnpmLock = existsSync(join(cwd, "pnpm-lock.yaml"));
const pnpmBin = whichBinary("pnpm");
const npmBin = whichBinary("npm");
const dockerBin = whichBinary("docker");View on GitHub (pinned to e04ba88819)
Solutions
- Read the ≤300-char message — it is the child process's stderr/stdout and names the real failing tool and reason.
- Re-run the failing command manually in the project directory to see full output.
- Install or update the missing dependency the subprocess complained about (e.g. correct Node version, build tools).
- Check PATH and file permissions for the invoked binary, and that options.cwd points at the right directory.
- If the step is genuinely optional in your environment, ignore the '(skipped)' warning — setup continues.
Example fix
// before
if (!runCommand('npx', ['some-tool', '--check'], { label: 'Checking tool', optional: true })) {
// message truncated to 300 chars, hard to diagnose
}
// after — capture full output for diagnosis when the step matters
const r = spawnSync('npx', ['some-tool', '--check'], { encoding: 'utf-8' });
if (r.status !== 0) console.error('tool failed:', (r.stderr || r.stdout || '').toString()); Defensive patterns
Strategy: validation
Validate before calling
import { spawnSync } from 'node:child_process';
// pre-flight: confirm the binary exists and is executable before runCommand
const which = spawnSync('which', [command], { encoding: 'utf-8' });
if (which.status !== 0) throw new Error(`${command} not found on PATH`); Try / catch
const result = spawnSync(command, args, { encoding: 'utf-8' });
if (result.status !== 0 || result.error) {
const msg = (result.stderr || result.stdout || result.error?.message || 'unknown error').toString().slice(0, 300);
p.log.warn(msg);
} Prevention
- Ensure required binaries (node, npm, etc.) are on PATH and at supported versions before running CLI setup.
- Run CLI setup/doctor commands with correct cwd and sufficient permissions (not as a restricted user without exec rights).
- When a message is truncated at 300 chars, re-run the underlying command manually for full stderr.
- Treat '(skipped)' warnings on optional steps as non-fatal, but investigate if functionality you need depends on that step.
- In CI/containers, install build prerequisites in the image so optional doctor steps pass.
When it happens
Trigger: Raised at src/cli.ts:3145 (warning path) when `options.optional` is true and the spawned command exits non-zero — e.g. an optional doctor/setup check failing during `agentmemory` init or upgrade flows.
Common situations: Missing or too-old dependency binary (node, npm, sqlite3) emitting a stderr error; permission denied on an executable; optional postinstall/doctor steps failing in restricted environments (containers, minimal images); wrong cwd for the spawned command.
Related errors
- POST ${url} failed: ${res.status} ${res.statusText}${suffix}
- agentmemory: could not locate bundled plugin/ directory (sea
- observe failed for ${obs.toolName}: ${res.status} ${res.stat
- EEXIST
- ${adapter.displayName}: guideline not written (${gerr instan
AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30).
Data as JSON: /api/errors/82fd6ea0ee926454.
Report an issue: GitHub.