JuliusBrussee/caveman · error · Error

[mcp_servers.caveman-cloud] exists but is not…

Error message

[mcp_servers.caveman-cloud] exists but is not Caveman-journaled; refusing overwrite

What it means

For Codex, setup checks config.toml for a [mcp_servers.caveman-cloud] section. If present but no Caveman journal marker exists for it, the entry may be user-created or foreign, so the CLI refuses to overwrite it — mirroring the Claude-side guard.

Solutions

  1. Delete the manual [mcp_servers.caveman-cloud] section from codex config.toml and let setup install it journaled
  2. Recreate the Caveman marker for the codex caveman-cloud server if the entry is genuinely Caveman-managed
  3. Rename your manual server section to a non-colliding name

Example fix

// before (config.toml)
[mcp_servers.caveman-cloud]
command = "my-own-command"
// after
// remove the section, then run setup so it is installed with a journal marker
Defensive patterns

Strategy: validation

Validate before calling

const config = readFileSync(join(codexHomeDir(), 'config.toml'), 'utf8');
if (config.includes('[mcp_servers.caveman-cloud]') && !readMcpServerMarker('codex', 'caveman-cloud')) {
  console.error('Unjournaled caveman-cloud section in config.toml; remove it or restore the marker.');
}

Try / catch

try {
  runSetup('codex');
} catch (e) {
  if (String(e.message).includes('not Caveman-journaled')) {
    // delete the [mcp_servers.caveman-cloud] section from config.toml and re-run setup
  }
}

Prevention

When it happens

Trigger: Running setup for codex when the config contains the literal section header '[mcp_servers.caveman-cloud]' but readMcpServerMarker('codex','caveman-cloud') returns null.

Common situations: User hand-added the server to ~/.codex/config.toml; marker file removed by a cleaner; migrating from an older install that did not write markers.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/978a46ae0480a16b. Report an issue: GitHub.

Appendix: source

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

    if (current && !current.equals(Buffer.from(body)) && (!previous || bytesHash(current) !== previous.after_sha256)) {
      throw new Error(`${file} changed after setup; refusing to overwrite user skill edits`);
    }
  }
  if (agent === "claude") {
    const actual = claudeMcpRegistration("caveman-cloud");
    const marker = readMcpServerMarker("claude", "caveman-cloud");
    if (actual.present && !marker) {
      throw new Error("Claude caveman-cloud MCP exists but is not Caveman-journaled; refusing overwrite");
    }
    if (actual.present && marker && !agentNativeCloudMcpMatches("claude", marker)) {
      throw new Error("Claude caveman-cloud MCP changed after setup; refusing to overwrite user fields");
    }
    return;
  }
  const config = fileBytes(join(codexHomeDir(), "config.toml"))?.toString("utf8") ?? "";
  if (!config.includes("[mcp_servers.caveman-cloud]")) return;
  if (!readMcpServerMarker("codex", "caveman-cloud")) {
    throw new Error("[mcp_servers.caveman-cloud] exists but is not Caveman-journaled; refusing overwrite");
  }
}

function installAgentNativeBundleSkills(agent: "claude" | "codex", journal: AgentNativeBundleJournal): void {
  const originals = new Map(journal.skills.map((skill) => [skill.file, skill.before_base64]));
  journal.skills = agentNativeSkillFiles(agent).map(({ file, body }) => {
    mkdirSync(dirname(file), { recursive: true });
    atomicWriteFile(file, Buffer.from(body));
    return {
      file,
      before_base64: originals.get(file) ?? null,
      after_sha256: bytesHash(Buffer.from(body)),
    };
  });
}

function verifyAgentNativeBundle(agent: "claude" | "codex", journal: AgentNativeBundleJournal, cloudMcp: { command: string; args: string[] }): void {
  const status = nativeIntegrationStatus(agent);

View on GitHub (pinned to 3ee70a1026)