{"record":{"id":"f056d0c9948205ec","repo":"rtk-ai/rtk","slug":"gemini-support-is-global-only-use-rtk-init-g","errorCode":null,"errorMessage":"Gemini support is global-only. Use: rtk init -g --gemini","messagePattern":"Gemini support is global-only\\. Use: rtk init -g --gemini","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":5887,"sourceCode":"/// Gemini hook wrapper script — delegates to `rtk hook gemini`\nconst GEMINI_HOOK_SCRIPT: &str = r#\"#!/bin/bash\nexec rtk hook gemini\n\"#;\n\nfn resolve_gemini_dir() -> Result<PathBuf> {\n    resolve_home_subdir(GEMINI_DIR)\n}\n\n/// Entry point for `rtk init --gemini`\npub fn run_gemini(\n    global: bool,\n    hook_only: bool,\n    patch_mode: PatchMode,\n    ctx: InitContext,\n) -> Result<()> {\n    let InitContext { dry_run, .. } = ctx;\n    if !global {\n        anyhow::bail!(\"Gemini support is global-only. Use: rtk init -g --gemini\");\n    }\n\n    let gemini_dir = resolve_gemini_dir()?;\n    if !dry_run {\n        fs::create_dir_all(&gemini_dir).with_context(|| {\n            format!(\n                \"Failed to create Gemini config dir: {}\",\n                gemini_dir.display()\n            )\n        })?;\n    }\n\n    // 1. Install hook script\n    let hook_dir = gemini_dir.join(\"hooks\");\n    if !dry_run {\n        fs::create_dir_all(&hook_dir)\n            .with_context(|| format!(\"Failed to create hook dir: {}\", hook_dir.display()))?;\n    }","sourceCodeStart":5869,"sourceCodeEnd":5905,"githubUrl":"https://github.com/rtk-ai/rtk/blob/0924356b4caba4989607227b7c8824d3d8098719/src/hooks/init.rs#L5869-L5905","documentation":"rtk's Gemini integration can only be installed at the user/global level (~/.gemini), never per-project. setup_gemini checks the `global` flag and bails with anyhow before touching the filesystem if it was not set. The message tells the exact command to rerun with.","triggerScenarios":"Running `rtk init --gemini` (or programmatically calling setup_gemini with global=false). Any invocation that requests Gemini hooks without the -g flag hits this bail immediately.","commonSituations":"Developer wants Gemini integration for a single project and omits -g; scripts/CI generated from older rtk docs before the global-only policy; muscle memory from other agents (like Claude) where rtk init supports project-local hooks.","solutions":["Rerun with the global flag: `rtk init -g --gemini`","If per-project Gemini hooks were the goal, note they are unsupported; install globally and rely on shared config","Check `rtk init --help` for current flag layout (--agent vs --gemini)"],"exampleFix":"// before\nrtk init --gemini\n// after\nrtk init -g --gemini","handlingStrategy":"validation","validationCode":"// shell check before invoking\nif ! [[ \"$*\" == *\" -g\"* || \"$*\" == *\" --global\"* ]]; then echo \"Gemini requires global: rtk init -g --gemini\" >&2; exit 2; fi","typeGuard":null,"tryCatchPattern":"// treat bail as exit code 1 with this message; detect and rewrite the command\nrtk init --gemini || { echo \"retrying globally\"; rtk init -g --gemini; }","preventionTips":["Always pair --gemini with -g in scripts and docs","Check `rtk init --help` before scripting against init flags","Remember rtk's agent integrations differ in scoping: Claude is project-local, Gemini/Vibe are global"],"tags":["cli","init","gemini","global-only"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"0924356b4caba4989607227b7c8824d3d8098719","analyzedAt":"2026-09-19T19:25:29.612Z","contentChangedAt":"2026-09-19T19:25:29.612Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}