{"record":{"id":"9ba5c1a571d7ee32","repo":"rtk-ai/rtk","slug":"uninstall-only-works-with-global-flag-for-local-9ba5c1","errorCode":null,"errorMessage":"Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md","messagePattern":"Uninstall only works with --global flag\\. For local projects, manually remove RTK from AGENTS\\.md","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/hooks/init.rs","lineNumber":892,"sourceCode":"        for item in removed {\n            println!(\"  - {}\", item);\n        }\n        if !dry_run {\n            println!(\"\\nRestart Claude Code, OpenCode, and Cursor (if used) to apply changes.\");\n        }\n    }\n\n    if dry_run {\n        print_dry_run_footer();\n    }\n\n    Ok(())\n}\n\nfn uninstall_codex(global: bool, ctx: InitContext) -> Result<()> {\n    let InitContext { dry_run, .. } = ctx;\n    if !global {\n        anyhow::bail!(\n            \"Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md\"\n        );\n    }\n\n    let codex_dir = resolve_codex_dir()?;\n    let removed = uninstall_codex_at(&codex_dir, ctx)?;\n\n    if removed.is_empty() {\n        println!(\"RTK was not installed for Codex CLI (nothing to remove)\");\n    } else {\n        let header = if dry_run {\n            \"[dry-run] would uninstall RTK for Codex CLI:\"\n        } else {\n            \"RTK uninstalled for Codex CLI:\"\n        };\n        println!(\"{}\", header);\n        for item in removed {\n            println!(\"  - {}\", item);","sourceCodeStart":874,"sourceCodeEnd":910,"githubUrl":"https://github.com/rtk-ai/rtk/blob/36788f6bd4932037caac5cbb1d15d6e2fb9f33da/src/hooks/init.rs#L874-L910","documentation":"uninstall_codex() removes the Codex notify plugin and AGENTS.md markers, which only exist in the global Codex config directory, so it requires --global. When invoked with global=false it bail!s, pointing users at manually deleting the RTK block from local AGENTS.md files.","triggerScenarios":"Running `rtk uninstall --codex` without `-g`/`--global`. Fires at the top of uninstall_codex() before resolve_codex_dir().","commonSituations":"Users who ran `rtk init --codex -g` and later attempt a local uninstall; cleanup scripts parameterized for local scope.","solutions":["Run `rtk uninstall -g --codex` (add --dry-run to preview removals)","For project-local AGENTS.md RTK blocks, delete the section manually","Verify removal afterwards by checking the global Codex directory no longer contains the rtk notify plugin"],"exampleFix":"// before\nrtk uninstall --codex\n// after\nrtk uninstall -g --codex","handlingStrategy":"validation","validationCode":"const args = process.argv.slice(2);\nif (args[0] === 'uninstall' && args.includes('--codex')\n    && !args.includes('-g') && !args.includes('--global')) {\n  throw new Error('Codex uninstall is global-only; add -g');\n}","typeGuard":null,"tryCatchPattern":"try {\n  execFileSync('rtk', ['uninstall', '-g', '--codex', '--dry-run'], { stdio: 'inherit' });\n} catch (e) {\n  if (String(e.stderr).includes('global flag')) {\n    console.error('Codex uninstall requires -g; local AGENTS.md edits are manual.');\n  }\n  throw e;\n}","preventionTips":["Codex integration is global-only on both install and uninstall; keep -g on both","Manually clean any RTK block you added to project AGENTS.md files","Use --dry-run to verify the Codex plugin removal path before executing"],"tags":["cli","argument-validation","global-only","uninstall","codex"],"backgroundTag":"global-only-flag-required","analyzedSha":"36788f6bd4932037caac5cbb1d15d6e2fb9f33da","analyzedAt":"2026-09-03T16:33:57.738Z","contentChangedAt":"2026-09-03T16:33:57.738Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}