{"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":6425,"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":6407,"sourceCodeEnd":6443,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/27d5a3981a347890211bb1bf2439e5c821a63bc9/packages/cli/src/index.ts#L6407-L6443","documentation":"aiderNativeMutations() writes the Caveman core instructions to ~/.caveman/packs/aider/CAVEMAN.md (aiderCorePath()) and treats that file as fully Caveman-owned: it may only exist if its bytes exactly equal aiderCoreSource(). Any divergence means someone edited Caveman's managed file, so it refuses to overwrite.","triggerScenarios":"Native Aider install when CAVEMAN.md exists under ~/.caveman/packs/aider/ and its content differs (even by whitespace) from the version the current CLI generates — e.g. after a caveman upgrade changed NATIVE_CORE.","commonSituations":"User customized the core markdown; leftover file from an older caveman version whose generated content differs; partially updated installs.","solutions":["If you customized it, back it up (cp CAVEMAN.md CAVEMAN.md.custom), then delete the original","Otherwise simply delete ~/.caveman/packs/aider/CAVEMAN.md so the install regenerates the current exact content","Re-run the caveman aider install"],"exampleFix":"# before\n$ caveman native install aider\nError: ~/.caveman/packs/aider/CAVEMAN.md exists and is not exact Caveman-owned content; refusing to overwrite it\n\n# after\n$ mv ~/.caveman/packs/aider/CAVEMAN.md ~/CAVEMAN.md.bak\n$ caveman native install aider   # regenerates exact content","handlingStrategy":"validation","validationCode":"import { readFileSync } from \"node:fs\";\nfunction aiderCoreExact(path: string, expected: string): boolean {\n  try { return readFileSync(path, \"utf8\") === expected; } catch { return true; } // absent is fine\n}","typeGuard":null,"tryCatchPattern":"try { nativeInstallAider(); } catch (e) {\n  if (e instanceof Error && /not exact Caveman-owned content/.test(e.message)) {\n    backUpAndDelete(corePath); nativeInstallAider();\n  } else throw e;\n}","preventionTips":["Treat files under ~/.caveman/packs as generated artifacts: never hand-edit them","After upgrading caveman, delete stale pack files if installs complain","Keep custom instructions in your own file added via read:, not in CAVEMAN.md"],"tags":["aider","ownership","managed-file","refuse-overwrite","version-drift"],"backgroundTag":null,"analyzedSha":"27d5a3981a347890211bb1bf2439e5c821a63bc9","analyzedAt":"2026-08-15T09:26:11.751Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}