JuliusBrussee/caveman · error

agent-native setup failed: ${(error as Error).message}${roll

Error message

agent-native setup failed: ${(error as Error).message}${rollbackErrors.length ? `; rollback incomplete: ${rollbackErrors.join("; ")}` : "; changes rolled back"}

What it means

Top-level failure of the agent-native setup path: something threw after partial application (skill writes, caveman-cloud MCP registration, native enablement). The handler rolls back applied skills, the cloud MCP (if applied), disables the native agent if it was not previously installed, and drops the pending journal; the message reports whether rollback fully succeeded or lists rollback errors.

Source

Thrown at packages/cli/src/index.ts:2713

      try {
        ensureAgentNativeIntegration(agentNative);
        installAgentNativeCloudMcp(agentNative, cloudMcp);
        cloudMcpApplied = true;
        installAgentNativeBundleSkills(agentNative, journal);
        verifyAgentNativeBundle(agentNative, journal, cloudMcp);
        atomicWriteFile(agentNativeBundleJournalPath(agentNative), Buffer.from(JSON.stringify(journal, null, 2) + "\n"));
        unlinkSync(agentNativeBundleJournalPath(agentNative, true));
      } catch (error) {
        const rollbackErrors: string[] = [];
        try { restoreAgentNativeBundleSkills(rollbackSkills); } catch (rollback) { rollbackErrors.push((rollback as Error).message); }
        if (cloudMcpApplied) {
          try { restoreAgentNativeCloudMcp(agentNative, rollbackCloudMcp); } catch (rollback) { rollbackErrors.push((rollback as Error).message); }
        }
        if (!nativeWasInstalled) {
          try { disableNativeAgent(agentNative); } catch (rollback) { rollbackErrors.push((rollback as Error).message); }
        }
        try { unlinkSync(agentNativeBundleJournalPath(agentNative, true)); } catch { /* original error remains authority */ }
        throw new Error(`agent-native setup failed: ${(error as Error).message}${rollbackErrors.length ? `; rollback incomplete: ${rollbackErrors.join("; ")}` : "; changes rolled back"}`);
      }
      const coreState = nativeCoreRuntimeState();
      const coreLabel = coreState.active ? "on" : coreState.configured ? "configured on; inactive under record mode/profile" : "off";
      console.error(`${mark("ok")} ${agentNative}: complete agent-native bundle ready`);
      console.error(dim(`→ coding policy: Core ${NATIVE_PACK.version} ${coreLabel}; change with \`caveman tools config set think.core ${coreState.configured ? "off" : "on"}\`; start new session to clear delivered context`));
      console.error(dim(`→ remove complete bundle: \`caveman setup --agent-native ${agentNative} --remove\``));
      console.error(dim("→ log in with `caveman login`; agent reads project context through existing CLI credentials"));
    });
  }
  if (install) return setupInstall(json);

  const rows = GO_BINARIES.map((b) => ({ ...b, resolved: resolveGoBin(b.name, b.env) }));
  const missingRequired = rows.filter((r) => r.required && !r.resolved);

  if (json) {
    print({
      binaries: rows.map((row) => ({
        name: row.name,

View on GitHub (pinned to 27d5a3981a)

Solutions

  1. If the message ends with 'changes rolled back', fix the named original error and re-run setup
  2. If rollback was incomplete, follow each rollback error: close the agent, repair permissions, then re-run setup — the recovery paths reconcile pending journals
  3. As a last resort, restore the agent config from backup and delete the agent-native journals under the caveman state directory before re-running setup
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-flight for agent-native setup
import { accessSync, constants } from "node:fs";
accessSync(join(homedir(), ".claude"), constants.W_OK);
accessSync(join(homedir(), ".codex"), constants.W_OK);
if (await isProcessRunning("claude") || await isProcessRunning("codex")) {
  throw new Error("close running agents before agent-native setup");
}

Try / catch

try {
  await setup(["--agent-native", agent]);
} catch (error) {
  const msg = (error as Error).message;
  if (/agent-native setup failed/.test(msg)) {
    if (/rollback incomplete/.test(msg)) {
      // partial state on disk: next setup run reconciles via pending journals; fix causes first
      await fixRollbackCauses(msg);
      await setup(["--agent-native", agent]);
    }
    // 'changes rolled back' => environment clean; fix the original error then retry
    else { await fixOriginalCause(msg); await setup(["--agent-native", agent]); }
  } else throw error;
}

Prevention

When it happens

Trigger: Any exception during `caveman setup --agent-native claude|codex` after changes began: unwritable agent config, MCP registration mismatch detected mid-flight, native enablement failure. Rollback errors appear when the same filesystem conditions break restoration.

Common situations: Agent running and rewriting its config during setup; home directory permissions changed mid-run; partial disk failure. '; changes rolled back' suffix means clean state; '; rollback incomplete: ...' means manual repair needed.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15). Data as JSON: /api/errors/1bf6ff2bed99f68e. Report an issue: GitHub.