JuliusBrussee/caveman · error
Aider config has duplicate read keys; refusing unsafe merge
Error message
Aider config has duplicate read keys; refusing unsafe merge
What it means
aiderNativeConfig() appends the Caveman core markdown path into Aider's `read:` list in ~/.aider.conf.yml. If the file declares two or more `read:` keys, which list Aider actually uses is ambiguous, so the tool refuses an unsafe merge.
Source
Thrown at packages/cli/src/index.ts:6397
function aiderNativeConfig(source: string, route: string, corePath: string): { text: string; routeBlock: string; previousRouteLine: string | null; readBlock: string } {
if ([AIDER_NATIVE_ROUTE_BEGIN, AIDER_NATIVE_ROUTE_END, AIDER_NATIVE_READ_BEGIN, AIDER_NATIVE_READ_END].some((marker) => source.includes(marker))) {
throw new Error("existing Aider Caveman block is unjournaled; run `caveman doctor aider`");
}
const newline = source.includes("\r\n") ? "\r\n" : "\n";
const lines = source.replace(/\r\n/g, "\n").split("\n");
const routeIndexes = lines.flatMap((line, index) => /^openai-api-base\s*:/.test(line) ? [index] : []);
if (routeIndexes.length > 1) throw new Error("Aider config has duplicate openai-api-base keys; refusing unsafe merge");
const routeBlockLines = [AIDER_NATIVE_ROUTE_BEGIN, `openai-api-base: ${yamlQuote(route)}`, AIDER_NATIVE_ROUTE_END];
const routeBlock = routeBlockLines.join(newline);
const previousRouteLine = routeIndexes.length === 1 ? lines[routeIndexes[0]!]! : null;
if (routeIndexes.length === 1) lines.splice(routeIndexes[0]!, 1, ...routeBlockLines);
else {
if (lines.some((line) => line.trim() !== "") && lines[lines.length - 1]?.trim()) lines.push("");
lines.push(...routeBlockLines);
}
const readIndexes = lines.flatMap((line, index) => /^read\s*:/.test(line) ? [index] : []);
if (readIndexes.length > 1) throw new Error("Aider config has duplicate read keys; refusing unsafe merge");
let readBlockLines: string[];
if (readIndexes.length === 1) {
const readIndex = readIndexes[0]!;
if (!/^read\s*:\s*(?:#.*)?$/.test(lines[readIndex]!)) {
throw new Error("Aider config uses inline/scalar read; use block-list form before enabling Caveman");
}
let end = readIndex + 1;
while (end < lines.length && !/^[A-Za-z0-9][A-Za-z0-9_-]*\s*:/.test(lines[end]!)) end++;
readBlockLines = [` ${AIDER_NATIVE_READ_BEGIN}`, ` - ${yamlQuote(corePath)}`, ` ${AIDER_NATIVE_READ_END}`];
lines.splice(end, 0, ...readBlockLines);
} else {
if (lines.some((line) => line.trim() !== "") && lines[lines.length - 1]?.trim()) lines.push("");
readBlockLines = [AIDER_NATIVE_READ_BEGIN, "read:", ` - ${yamlQuote(corePath)}`, AIDER_NATIVE_READ_END];
lines.push(...readBlockLines);
}
const readBlock = readBlockLines.join(newline);
const text = lines.join(newline).replace(/(?:\r?\n)+$/, "") + newline;
return { text, routeBlock, previousRouteLine, readBlock };View on GitHub (pinned to 27d5a3981a)
Solutions
- Merge the contents of the duplicate read: lists into a single read: block-list
- Delete the redundant key, keeping one read: entry
- Re-run the caveman aider install
Example fix
# before read: - ./CONVENTIONS.md read: - ./OTHER.md # after read: - ./CONVENTIONS.md - ./OTHER.md
Defensive patterns
Strategy: validation
Validate before calling
import { readFileSync } from "node:fs";
function aiderNoDuplicateRead(path: string): boolean {
try { return readFileSync(path, "utf8").split(/\r?\n/).filter((l) => /^read\s*:/.test(l)).length <= 1; }
catch { return true; }
} Try / catch
try { nativeInstallAider(); } catch (e) {
if (e instanceof Error && /duplicate read keys/.test(e.message)) {
mergeAiderReadLists(); nativeInstallAider();
} else throw e;
} Prevention
- Maintain a single read: block-list in .aider.conf.yml
- Merge lists when combining config snippets instead of adding a second key
- Run yamllint on aider config before integrations touch it
When it happens
Trigger: Native Aider install when ~/.aider.conf.yml contains two or more lines matching /^read\s*:/ at top level.
Common situations: Copy-pasted config snippets adding a second read: block; merge conflicts in dotfile git repos; hand edits that appended instead of merged.
Related errors
- Aider config has duplicate openai-api-base keys; refusing un
- Aider config uses inline/scalar read; use block-list form be
- Hermes model provider/base_url keys are duplicated; refusing
- existing Aider Caveman block is unjournaled; run `caveman do
- Hermes plugins.enabled uses inline YAML; refusing unsafe nat
AI-assisted analysis of JuliusBrussee/caveman@27d5a3981a (2026-08-15).
Data as JSON: /api/errors/f318d5cf1048122c.
Report an issue: GitHub.