{"record":{"id":"f30085bb32b398d0","repo":"JuliusBrussee/caveman","slug":"corepath-exists-and-is-not-exact-caveman-owned","errorCode":null,"errorMessage":"${corePath} exists and is not exact Caveman-owned content; refusing to overwrite it","messagePattern":"(.+?) exists and is not exact Caveman-owned content; refusing to overwrite it","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":7454,"sourceCode":"    lines.splice(end, 0, ...readBlockLines);\n  } else {\n    if (lines.some((line) => line.trim() !== \"\") && lines[lines.length - 1]?.trim()) lines.push(\"\");\n    readBlockLines = [AIDER_NATIVE_READ_BEGIN, \"read:\", `  - ${yamlQuote(corePath)}`, AIDER_NATIVE_READ_END];\n    lines.push(...readBlockLines);\n  }\n  const readBlock = readBlockLines.join(newline);\n  const text = lines.join(newline).replace(/(?:\\r?\\n)+$/, \"\") + newline;\n  return { text, routeBlock, previousRouteLine, readBlock };\n}\n\nfunction aiderNativeMutations(gw: string): NativeMutation[] {\n  const configPath = join(homedir(), \".aider.conf.yml\");\n  const configBefore = fileBytes(configPath);\n  const corePath = aiderCorePath();\n  const coreBefore = fileBytes(corePath);\n  const core = aiderCoreSource();\n  if (coreBefore && coreBefore.toString(\"utf8\") !== core) {\n    throw new Error(`${corePath} exists and is not exact Caveman-owned content; refusing to overwrite it`);\n  }\n  const route = appendUrlPath(gw, \"/w/aider/openai/v1\");\n  const native = aiderNativeConfig(configBefore?.toString(\"utf8\") ?? \"\", route, corePath);\n  return [\n    {\n      file: configPath,\n      before: configBefore,\n      after: Buffer.from(native.text),\n      kind: \"aider-config\",\n      owned: { route, route_block: native.routeBlock, previous_route_line: native.previousRouteLine, read_block: native.readBlock, core_path: corePath },\n    },\n    {\n      file: corePath,\n      before: coreBefore,\n      after: Buffer.from(core),\n      kind: \"aider-core\",\n      owned: { marker: AIDER_NATIVE_CORE_MARKER },\n    },","sourceCodeStart":7436,"sourceCodeEnd":7472,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L7436-L7472","documentation":"The Aider installer generates the Caveman core source and writes it to aiderCorePath(). If a file already exists at that path and its byte content is not exactly equal to the generated core source, the installer refuses to overwrite it, since it cannot verify the file is Caveman-owned/current.","triggerScenarios":"Running the Aider enable flow when the core file exists but its contents differ from the currently generated core (edited by hand, truncated, or produced by a different Caveman version with different core text).","commonSituations":"Users tweaking the core prompt file to customize behavior; a Caveman upgrade changed NATIVE_CORE text so an old core file no longer matches byte-for-byte; partial writes from an interrupted install.","solutions":["Delete (or back up and remove) the existing core file and re-run the enable command so Caveman writes a fresh copy.","Run `caveman doctor aider` to detect and repair the stale core file.","If you customized the core, save your changes elsewhere, delete the file, re-enable, then reapply customizations understanding they may be overwritten on upgrade.","If a version upgrade caused the mismatch, reinstall via the current `caveman` version so core text matches."],"exampleFix":"// before: core file edited, mismatch with generated source\ncat ~/.config/caveman/aider-core.md  # hand-edited content\n// after\nmv ~/.config/caveman/aider-core.md ~/aider-core.md.bak\ncaveman enable aider  # rewrites exact generated core with AIDER_NATIVE_CORE_MARKER","handlingStrategy":"validation","validationCode":"import { readFileSync, existsSync } from 'fs';\nconst corePath = aiderCorePath();\nif (existsSync(corePath) && readFileSync(corePath, 'utf8') !== expectedCoreSource()) {\n  // delete or restore the core file before enabling\n}","typeGuard":null,"tryCatchPattern":"try {\n  await cavemanEnableAider();\n} catch (e) {\n  if (String(e.message).includes('not exact Caveman-owned content')) {\n    rename(corePath, corePath + '.bak');\n    await cavemanEnableAider();\n  }\n}","preventionTips":["Treat the generated Aider core file as owned by Caveman; do not edit it.","Store custom prompt changes in separate Aider conventions files.","Re-run the installer (not manual edits) after Caveman upgrades so the core text stays current.","Use `caveman doctor aider` to detect core drift."],"tags":["aider","install","refuse-overwrite","drift"],"backgroundTag":"file-already-exists","analyzedSha":"3ee70a102609e550bd2e68004bf5990a9341c851","analyzedAt":"2026-09-20T15:53:39.229Z","contentChangedAt":"2026-09-20T15:53:39.229Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}