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

  1. Read the ≤300-char message — it is the child process's stderr/stdout and names the real failing tool and reason.
  2. Re-run the failing command manually in the project directory to see full output.
  3. Install or update the missing dependency the subprocess complained about (e.g. correct Node version, build tools).
  4. Check PATH and file permissions for the invoked binary, and that options.cwd points at the right directory.
  5. 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

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


AI-assisted analysis of rohitg00/agentmemory@e04ba88819 (2026-08-30). Data as JSON: /api/errors/82fd6ea0ee926454. Report an issue: GitHub.