JuliusBrussee/caveman · error

already exists; refusing to overwrite an unjournaled plugin

Error message

${path} already exists; refusing to overwrite an unjournaled plugin

What it means

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.

Solutions

  1. Back up and remove or rename the existing plugin.yaml and __init__.py in the Hermes plugin directory, then rerun the command.
  2. Run the tool's recovery/`--fix` flow so any interrupted install is journalled and rolled back before retrying.
  3. Point HERMES at a different plugin directory if the existing plugin is intentional.
  4. Manually merge the native plugin manifest/init content into the existing files and skip the automated install.

Example fix

// before (naive retry)
installHermesNative();
// after
for (const p of [manifestPath, initPath]) if (existsSync(p)) renameSync(p, p + ".bak");
installHermesNative();
Defensive patterns

Strategy: validation

Validate before calling

import { existsSync } from "node:fs";
const conflict = [join(pluginDir, "plugin.yaml"), join(pluginDir, "__init__.py")].filter(existsSync);
if (conflict.length) console.error("remove or reconcile first:", conflict);

Type guard

const pluginDirIsClear = (dir: string) => !existsSync(join(dir, "plugin.yaml")) && !existsSync(join(dir, "__init__.py"));

Try / catch

try { installHermesNative(); } catch (e) { if (String(e.message).includes("refusing to overwrite")) archiveExistingPlugin(pluginDir); }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.

Related errors


AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20). Data as JSON: /api/errors/cb6e3654e41360f8. Report an issue: GitHub.

Appendix: source

Thrown at packages/cli/src/index.ts:7813

    owned: {
      route: appendUrlPath(gw, "/w/hermes/v1"),
      route_block: routeBlock.join("\n"),
      previous_route_lines: previousRouteLines,
      plugin_block: pluginBlock,
      mcp_block: mcpBlock,
    },
  };
}

function hermesNativeMutations(gw: string, mcpBinary: string): NativeMutation[] {
  const configPath = hermesConfigPath();
  const configBefore = fileBytes(configPath);
  const native = hermesNativeConfig(configBefore?.toString("utf8") ?? "", gw, mcpBinary);
  const pluginDir = hermesNativePluginDir();
  const manifestPath = join(pluginDir, "plugin.yaml");
  const initPath = join(pluginDir, "__init__.py");
  for (const path of [manifestPath, initPath]) {
    if (fileBytes(path)) throw new Error(`${path} already exists; refusing to overwrite an unjournaled plugin`);
  }
  return [
    { file: configPath, before: configBefore, after: Buffer.from(native.text), kind: "hermes-config", owned: native.owned },
    { file: manifestPath, before: null, after: Buffer.from(hermesNativePluginManifest()), kind: "hermes-plugin-manifest" },
    { file: initPath, before: null, after: Buffer.from(hermesNativePluginSource()), kind: "hermes-plugin-init" },
  ];
}

function withIntegrationLock<T>(agent: string, run: () => T): T {
  const lock = join(cavemanHome(), "integrations", `.lock-${agent}`);
  const ownerPath = join(lock, "owner.json");
  const token = randomUUID();
  mkdirSync(dirname(lock), { recursive: true, mode: 0o700 });
  try { mkdirSync(lock, { recursive: false, mode: 0o700 }); }
  catch (error) {
    if ((error as NodeJS.ErrnoException).code !== "EEXIST") throw error;
    let stale = false;
    try {

View on GitHub (pinned to 3ee70a1026)