JuliusBrussee/caveman · error · Error
changed during MCP update; refusing overwrite
Error message
${path} changed during MCP update; refusing overwrite What it means
Thrown by durableReplaceFileIfUnchanged when the target file's current bytes differ from the snapshot (expected) taken at the start of an MCP config update. This optimistic-concurrency check ensures the CLI never clobbers concurrent edits to config files during an MCP server installation/update.
Solutions
- Re-run the MCP update command alone, with no other process editing the config
- Close editors or pause file-sync tools that touch the config directory
- Avoid running concurrent `caveman setup`/MCP update commands in parallel
- Inspect the file for unexpected changes, then retry
Example fix
// before (concurrent) caveman setup --install & vim ~/.claude.json // after (sequential) vim ~/.claude.json && caveman setup --install
Defensive patterns
Strategy: retry
Validate before calling
// before updating, ensure no concurrent writers const before = fs.readFileSync(configPath); if (!fs.existsSync(lockPath)) fs.writeFileSync(lockPath, String(process.pid));
Type guard
null
Try / catch
try {
runMcpUpdate();
} catch (e) {
if (String(e.message).includes("changed during MCP update")) {
// safe: file was NOT overwritten; just retry
retryWithBackoff(runMcpUpdate);
}
} Prevention
- Never run multiple setup/MCP update commands in parallel
- Pause cloud-sync (Dropbox/iCloud) on config directories during updates
- Close editors with autosave on agent config files before updating
- Use a lock file or serialized script when automating updates
When it happens
Trigger: Between reading the original bytes and the replace step, fileBytes(path) returns content different from `expected` — another process/user modified the file during the update.
Common situations: An editor, sync client (Dropbox/iCloud), or another agent run writing the same settings/mcp config while the CLI updates it; two setup commands run in parallel.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- changed during MCP update; refusing removal
- MCP transaction state kept changing; refusing mutation
- changed while planning MCP update; refusing overwrite
- changed while planning MCP update; refusing overwrite
- MCP config change already running for
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/ca5abca2c0996dc1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:6933
function durableCreateFile(path: string, bytes: Buffer, mode = 0o600): void {
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
const temp = join(dirname(path), `.${basename(path)}.caveman-create-${process.pid}-${randomUUID()}.tmp`);
try {
durableAtomicWriteFile(temp, bytes, mode);
linkSync(temp, path);
fsyncParentDirectory(path);
} finally {
try { unlinkSync(temp); } catch { /* published or failed before temp creation */ }
}
}
function optionalBytesEqual(left: Buffer | null, right: Buffer | null): boolean {
return left === null ? right === null : right !== null && left.equals(right);
}
function durableReplaceFileIfUnchanged(path: string, expected: Buffer | null, next: Buffer | null, mode = 0o600): void {
const current = fileBytes(path);
if (!optionalBytesEqual(current, expected)) throw new Error(`${path} changed during MCP update; refusing overwrite`);
if (next === null) {
if (current !== null) {
const atDelete = fileBytes(path);
if (!optionalBytesEqual(atDelete, expected)) throw new Error(`${path} changed during MCP update; refusing removal`);
unlinkSync(path);
fsyncParentDirectory(path);
}
return;
}
// Prepare durable replacement first, then run final compare immediately
// before rename. Per-agent lock serializes Caveman writers; this CAS catches
// external edits observed before commit without erasing them.
mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
const temp = join(dirname(path), `.${basename(path)}.caveman-cas-${process.pid}-${randomUUID()}.tmp`);
let fd: number | undefined;
try {
fd = openSync(temp, constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY, mode);View on GitHub (pinned to 3ee70a1026)