JuliusBrussee/caveman · error
managed Gemini CLI routing is unsupported because Gemini…
Error message
managed Gemini CLI routing is unsupported because Gemini CLI cannot send separate Caveman and upstream credentials
What it means
`geminiNativeMutations()` refuses to manage Gemini CLI routing in `managed` wrap mode because Gemini CLI cannot send separate Caveman and upstream credentials — a single auth channel means managed mode's credential separation is impossible. Native (local) wrap mode is required for Gemini.
Solutions
- Switch wrap mode to local/native for Gemini (e.g. remove the managed gateway setting or run with local mode) and re-run setup
- Use a supported agent (e.g. Claude CLI) if you must stay in managed wrap mode
- Check `caveman config`/env for the gateway/mode setting and change it to the local gateway URL
- Ask Caveman support/issue tracker if managed Gemini routing is available in newer versions
Example fix
// before CAVEMAN_GATEWAY=https://gw.managed.caveman.dev # managed mode // after CAVEMAN_GATEWAY=http://127.0.0.1:<local-port> # local wrap mode $ caveman setup
Defensive patterns
Strategy: validation
Validate before calling
// Ensure local wrap mode before configuring Gemini natively:
if (wrapMode(process.env.CAVEMAN_GATEWAY ?? '') === 'managed') {
throw new Error('Gemini CLI requires local wrap mode; switch off the managed gateway');
} Try / catch
try {
await cavemanSetup(['gemini']);
} catch (e) {
if (String(e.message).includes('managed Gemini CLI routing is unsupported')) {
// switch gateway config to local mode (or pick a supported agent) and retry
}
throw e;
} Prevention
- Use the local gateway when the agent is Gemini CLI; reserve managed mode for supported agents
- Check `caveman config` for the current wrap mode before running setup
- Document per-agent mode requirements in team onboarding docs
- Validate CAVEMAN_GATEWAY points at the local instance in shell profiles used for Gemini work
When it happens
Trigger: Calling `geminiNativeMutations(gw, mcpBinary)` while `wrapMode(gw) === "managed"` — i.e. the CLI is configured to route through a managed gateway but the user/native-integration path targets Gemini CLI.
Common situations: User switched their Caveman plan/config to a managed gateway (or set the managed gateway URL) but keeps using Gemini CLI as the agent; org config forces managed mode; running the same setup command across agents where managed mode works for Claude but not Gemini.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- cave_auth_required
- CAVEMAN_AUTH_TOKEN must be at least
- CAVEMAN_AUTH_TOKEN must contain no spaces or control…
- contents
- device credential delivery acknowledgement failed
AI-assisted analysis of JuliusBrussee/caveman@3ee70a1026 (2026-09-20).
Data as JSON: /api/errors/6f5772b678c56ee1.
Report an issue: GitHub.
Appendix: source
Thrown at packages/cli/src/index.ts:7106
const start = stripped.indexOf(GEMINI_NATIVE_ENV_BEGIN);
const finish = stripped.indexOf(GEMINI_NATIVE_ENV_END);
if ((start === -1) !== (finish === -1) || (start !== -1 && finish < start)) {
throw new Error("existing Gemini Caveman routing block is corrupted; run `caveman doctor gemini`");
}
if (start !== -1) stripped = `${stripped.slice(0, start)}${stripped.slice(finish + GEMINI_NATIVE_ENV_END.length)}`.trim();
const block = [
GEMINI_NATIVE_ENV_BEGIN,
`GEMINI_BASE_URL=${route}`,
`GOOGLE_GEMINI_BASE_URL=${route}`,
`GOOGLE_VERTEX_BASE_URL=${appendUrlPath(route, "/vertex")}`,
GEMINI_NATIVE_ENV_END,
].join("\n");
return { text: `${stripped}${stripped ? "\n\n" : ""}${block}\n`, block };
}
function geminiNativeMutations(gw: string, mcpBinary: string): NativeMutation[] {
if (wrapMode(gw) === "managed") {
throw new Error("managed Gemini CLI routing is unsupported because Gemini CLI cannot send separate Caveman and upstream credentials");
}
const settingsPath = geminiSettingsPath();
const settingsBefore = fileBytes(settingsPath);
const settings = parseJsonFileObject(settingsPath, settingsBefore);
assertNativeHooksShape(settingsPath, settings, "gemini");
if (settings.mcpServers !== undefined && (typeof settings.mcpServers !== "object" || settings.mcpServers === null || Array.isArray(settings.mcpServers))) {
throw new Error(`${settingsPath} mcpServers must be a JSON object; refusing to overwrite it`);
}
const servers = settings.mcpServers && typeof settings.mcpServers === "object" && !Array.isArray(settings.mcpServers)
? settings.mcpServers as Record<string, unknown>
: {};
const previousMcp = servers.caveman;
const installedMcp = { command: mcpBinary, args: [] };
servers.caveman = installedMcp;
settings.mcpServers = servers;
const withHooks = nativeHooksDocument("gemini", nativeShrinkEnabled(), settings);
const envPath = join(geminiConfigDir(), ".env");View on GitHub (pinned to 3ee70a1026)