JuliusBrussee/caveman · error

OpenCode baseURL changed after enable; refusing destructive…

Error message

OpenCode ${providerID} baseURL changed after enable; refusing destructive disable

What it means

During disable/uninstall, the tool rolls back OpenCode provider config it enabled earlier. Before mutating a provider (openai/anthropic), it verifies the recorded route baseURL still matches the live options.baseURL. If the user edited the baseURL after enable, the tool refuses to disable destructively rather than clobbering a hand-modified config.

Solutions

  1. Restore options.baseURL to the value recorded in the enable journal (operation.owned.routes[providerID]), then re-run disable.
  2. Manually edit the OpenCode config to remove Caveman's provider entries instead of using the disable command.
  3. If the new baseURL is intentional, re-run enable so the journal is refreshed, then disable.
  4. Delete the stale journal/operation state if you accept manual config management.

Example fix

// before (config.json)
"openai": { "options": { "baseURL": "https://my-proxy.example.com/v1" } }
// after - restore the journaled value before disabling
"openai": { "options": { "baseURL": "https://api.openai.com/v1" } }
Defensive patterns

Strategy: validation

Validate before calling

const cfg = JSON.parse(fs.readFileSync(opencodeConfig, 'utf8'));
for (const id of ['openai', 'anthropic']) {
  const b = cfg?.provider?.[id]?.options?.baseURL;
  if (b !== undefined && b !== journal.owned?.routes?.[id]) {
    throw new Error(`baseURL for ${id} differs from journaled value; resolve before disable`);
  }
}

Type guard

const hasCustomBaseURL = (cfg, id, routes) =>
  typeof cfg?.provider?.[id]?.options?.baseURL === 'string' &&
  cfg.provider[id].options.baseURL !== routes?.[id];

Try / catch

try {
  await caveman.disable(['opencode']);
} catch (err) {
  if (err.message.includes('baseURL changed after enable')) {
    console.error('Restore the journaled baseURL or disable manually:', err.message);
  } else throw err;
}

Prevention

When it happens

Trigger: Running the disable operation when opencode config providers["openai"|"anthropic"].options.baseURL is set and !== the baseURL recorded in operation.owned.routes[providerID].

Common situations: User pointed the provider at a proxy or self-hosted gateway (e.g. LiteLLM, Azure endpoint) after enabling Caveman, then tried to disable; tooling rewrote the config externally so the journaled route no longer matches.

Understand the failure class

Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.

Related errors


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

Appendix: source

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

    const text = current.toString("utf8");
    if (text.includes(GEMINI_NATIVE_ENV_BEGIN) && !text.includes(block)) {
      throw new Error("Gemini routing block changed after enable; refusing destructive disable");
    }
    return Buffer.from(text.replace(`${block}\n\n`, "").replace(`\n\n${block}\n`, "\n").replace(`${block}\n`, "").replace(block, ""));
  }
  if (operation.kind === "opencode-plugin" || operation.kind === "pi-extension") {
    throw new Error(`${operation.file} changed after enable; refusing destructive disable`);
  }
  if (operation.kind === "opencode-config") {
    const root = parseJsonFileObject(operation.file, current);
    const providers = root.provider && typeof root.provider === "object" && !Array.isArray(root.provider) ? root.provider as Record<string, unknown> : {};
    const routes = operation.owned?.routes && typeof operation.owned.routes === "object" && !Array.isArray(operation.owned.routes) ? operation.owned.routes as Record<string, unknown> : {};
    const previousRoutes = operation.owned?.previous_routes && typeof operation.owned.previous_routes === "object" && !Array.isArray(operation.owned.previous_routes) ? operation.owned.previous_routes as Record<string, unknown> : {};
    for (const providerID of ["openai", "anthropic"]) {
      const provider = providers[providerID] && typeof providers[providerID] === "object" && !Array.isArray(providers[providerID]) ? providers[providerID] as Record<string, unknown> : {};
      const options = provider.options && typeof provider.options === "object" && !Array.isArray(provider.options) ? provider.options as Record<string, unknown> : {};
      if (options.baseURL !== undefined && options.baseURL !== routes[providerID]) {
        throw new Error(`OpenCode ${providerID} baseURL changed after enable; refusing destructive disable`);
      }
      if (previousRoutes[providerID] === null || previousRoutes[providerID] === undefined) delete options.baseURL;
      else options.baseURL = previousRoutes[providerID];
      if (Object.keys(options).length > 0) provider.options = options;
      else delete provider.options;
      if (Object.keys(provider).length > 0) providers[providerID] = provider;
      else delete providers[providerID];
    }
    if (Object.keys(providers).length > 0) root.provider = providers;
    else delete root.provider;
    const mcp = root.mcp && typeof root.mcp === "object" && !Array.isArray(root.mcp) ? root.mcp as Record<string, unknown> : {};
    if (mcp.caveman !== undefined && JSON.stringify(mcp.caveman) !== JSON.stringify(operation.owned?.installed_mcp)) {
      throw new Error("OpenCode caveman MCP entry changed after enable; refusing destructive disable");
    }
    if (mcp.caveman !== undefined) {
      if (operation.owned?.previous_mcp === null || operation.owned?.previous_mcp === undefined) delete mcp.caveman;
      else mcp.caveman = operation.owned.previous_mcp;
    }

View on GitHub (pinned to 3ee70a1026)