{"record":{"id":"cb6e3654e41360f8","repo":"JuliusBrussee/caveman","slug":"path-already-exists-refusing-to-overwrite-an-u","errorCode":null,"errorMessage":"${path} already exists; refusing to overwrite an unjournaled plugin","messagePattern":"(.+?) already exists; refusing to overwrite an unjournaled plugin","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/cli/src/index.ts","lineNumber":7813,"sourceCode":"    owned: {\n      route: appendUrlPath(gw, \"/w/hermes/v1\"),\n      route_block: routeBlock.join(\"\\n\"),\n      previous_route_lines: previousRouteLines,\n      plugin_block: pluginBlock,\n      mcp_block: mcpBlock,\n    },\n  };\n}\n\nfunction hermesNativeMutations(gw: string, mcpBinary: string): NativeMutation[] {\n  const configPath = hermesConfigPath();\n  const configBefore = fileBytes(configPath);\n  const native = hermesNativeConfig(configBefore?.toString(\"utf8\") ?? \"\", gw, mcpBinary);\n  const pluginDir = hermesNativePluginDir();\n  const manifestPath = join(pluginDir, \"plugin.yaml\");\n  const initPath = join(pluginDir, \"__init__.py\");\n  for (const path of [manifestPath, initPath]) {\n    if (fileBytes(path)) throw new Error(`${path} already exists; refusing to overwrite an unjournaled plugin`);\n  }\n  return [\n    { file: configPath, before: configBefore, after: Buffer.from(native.text), kind: \"hermes-config\", owned: native.owned },\n    { file: manifestPath, before: null, after: Buffer.from(hermesNativePluginManifest()), kind: \"hermes-plugin-manifest\" },\n    { file: initPath, before: null, after: Buffer.from(hermesNativePluginSource()), kind: \"hermes-plugin-init\" },\n  ];\n}\n\nfunction withIntegrationLock<T>(agent: string, run: () => T): T {\n  const lock = join(cavemanHome(), \"integrations\", `.lock-${agent}`);\n  const ownerPath = join(lock, \"owner.json\");\n  const token = randomUUID();\n  mkdirSync(dirname(lock), { recursive: true, mode: 0o700 });\n  try { mkdirSync(lock, { recursive: false, mode: 0o700 }); }\n  catch (error) {\n    if ((error as NodeJS.ErrnoException).code !== \"EEXIST\") throw error;\n    let stale = false;\n    try {","sourceCodeStart":7795,"sourceCodeEnd":7831,"githubUrl":"https://github.com/JuliusBrussee/caveman/blob/3ee70a102609e550bd2e68004bf5990a9341c851/packages/cli/src/index.ts#L7795-L7831","documentation":"Before writing the Hermes native plugin files (plugin.yaml and __init__.py), the installer checks whether either file already exists on disk. Because every write is journaled, pre-existing files would indicate an install it did not perform; overwriting them could destroy user data not covered by the journal. The error aborts the install to avoid clobbering unjournaled content.","triggerScenarios":"Running a Hermes native integration command when `<pluginDir>/plugin.yaml` or `<pluginDir>/__init__.py` already exists and was not created (or journalled) by this tool.","commonSituations":"A previous install crashed before writing its journal; the user or another tool created a plugin at the same path; the plugin directory points at an existing hand-written Hermes plugin.","solutions":["Back up and remove or rename the existing plugin.yaml and __init__.py in the Hermes plugin directory, then rerun the command.","Run the tool's recovery/`--fix` flow so any interrupted install is journalled and rolled back before retrying.","Point HERMES at a different plugin directory if the existing plugin is intentional.","Manually merge the native plugin manifest/init content into the existing files and skip the automated install."],"exampleFix":"// before (naive retry)\ninstallHermesNative();\n// after\nfor (const p of [manifestPath, initPath]) if (existsSync(p)) renameSync(p, p + \".bak\");\ninstallHermesNative();","handlingStrategy":"validation","validationCode":"import { existsSync } from \"node:fs\";\nconst conflict = [join(pluginDir, \"plugin.yaml\"), join(pluginDir, \"__init__.py\")].filter(existsSync);\nif (conflict.length) console.error(\"remove or reconcile first:\", conflict);","typeGuard":"const pluginDirIsClear = (dir: string) => !existsSync(join(dir, \"plugin.yaml\")) && !existsSync(join(dir, \"__init__.py\"));","tryCatchPattern":"try { installHermesNative(); } catch (e) { if (String(e.message).includes(\"refusing to overwrite\")) archiveExistingPlugin(pluginDir); }","preventionTips":["Run the tool's recovery/--fix flow after any interrupted install before retrying.","Keep the Hermes plugin directory dedicated to caveman's generated plugin.","Back up plugin.yaml and __init__.py before manual edits in that directory."],"tags":["filesystem","conflict","hermes"],"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"}