JuliusBrussee/caveman · error
integration journal disappeared during repair
Error message
${target} integration journal disappeared during repair What it means
The repair command for a native agent integration takes an integration lock and re-reads the pending-install journal. If the journal file existed during recovery checks but is gone by the time `readNativeJournal` runs, the pending repair cannot proceed, so the CLI throws. This is an internal consistency guard against a journal vanishing mid-repair (deleted concurrently or by another cleanup path).
Solutions
- Re-run the repair command once — if a concurrent process completed the repair, the retry will see the consistent state
- Check `caveman <agent> status` to see if the integration is already enabled/repaired before repairing again
- If you deleted the journal manually, restore it from backup or run `caveman <agent> enable` fresh to recreate a clean journal
Defensive patterns
Strategy: retry
Validate before calling
import { existsSync } from 'node:fs';
if (existsSync(nativeJournalPath('codex'))) {
// journal present; safe to attempt repair
} Type guard
function journalReadable(path: string): boolean { return existsSync(path); } Try / catch
try {
await caveman.codex.repair();
} catch (err) {
if (err instanceof Error && err.message.includes('journal disappeared during repair')) {
// a concurrent process likely completed the repair; check status and retry if still pending
} else throw err;
} Prevention
- Run only one caveman integration command at a time; don't run enable/repair concurrently
- Never manually delete journal/state files under the caveman state directory
- Check `caveman <agent> status` first; skip repair when integration is already healthy
When it happens
Trigger: Running the native-integration repair command for an agent when the journal file at nativeJournalPath(target) is deleted between the recovery step and the read inside the locked section — e.g. another caveman process finishing/cleaning the pending install concurrently, or manual deletion of the journal file.
Common situations: Two caveman invocations racing (one repairs/completes the install while the second waits on the lock then finds the journal gone); user manually removing journal/state files from the caveman state directory to 'reset' things; crash-cleanup tooling removing temp state.
Understand the failure class
Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.
Related errors
- cannot read agent-native bundle journal
- : MCP ownership journal failed; native config may already…
- caveman-cloud MCP changed after setup; refusing destructive…
- caveman-cloud MCP changed during interrupted setup…
- caveman-cloud MCP changed during interrupted removal…
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/d6050e5ddd7260fa.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:8502
return false;
}
cleanupNativeAgentFiles(target, disabled);
const name = findAgent(target)?.display_name ?? target;
process.stderr.write(`${mark("ok")} ${name}: ${target === "aider" ? "shallow" : "native"} Caveman disabled; unrelated host edits preserved\n`);
return true;
}
function repairNativeAgent(target: NativeAgent): void {
if (!readNativeJournal(target) && !readPendingNativeJournal(target)) {
enableNative([target]);
return;
}
const profile = findAgent(target)!;
const gw = gatewayURL();
withIntegrationLock(target, () => {
recoverPendingNativeInstallUnlocked(target);
const journal = readNativeJournal(target);
if (!journal) throw new Error(`${target} integration journal disappeared during repair`);
if (!which(binOf(profile))) throw new Error(`${profile.display_name} not found on PATH`);
const mcpBinary = target === "aider" ? undefined : nativeMcpBinaryRequired();
nativeProxyBinaryRequired(gw);
const journalBytes = readFileSync(nativeJournalPath(target));
const current = restoreNativeJournalFiles(journal);
try {
const mutations = nativeMutationsFor(target, gw, mcpBinary);
applyNativeMutations(target, profile, mutations);
} catch (error) {
for (const item of current) {
try { writeNativeRestoration(item.file, item.bytes); } catch { /* original error remains authority */ }
}
atomicWriteFile(nativeJournalPath(target), journalBytes);
throw error;
}
});
process.stderr.write(`${mark("ok")} ${profile.display_name}: native Caveman repaired; unrelated host edits preserved\n`);
}View on GitHub (pinned to 3ee70a1026)