rtk-ai/rtk · error · anyhow::Error

Uninstall only works with --global flag. For local projects,

Error message

Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md

What it means

The Codex CLI integration writes to the global ~/.codex config (AGENTS.md instructions), so its uninstaller is also global-only; a project AGENTS.md is never auto-edited. Same policy as the general uninstall bail, but names AGENTS.md as the manual-edit target.

Source

Thrown at src/hooks/init.rs:874

        for item in removed {
            println!("  - {}", item);
        }
        if !dry_run {
            println!("\nRestart Claude Code, OpenCode, and Cursor (if used) to apply changes.");
        }
    }

    if dry_run {
        print_dry_run_footer();
    }

    Ok(())
}

fn uninstall_codex(global: bool, ctx: InitContext) -> Result<()> {
    let InitContext { dry_run, .. } = ctx;
    if !global {
        anyhow::bail!(
            "Uninstall only works with --global flag. For local projects, manually remove RTK from AGENTS.md"
        );
    }

    let codex_dir = resolve_codex_dir()?;
    let removed = uninstall_codex_at(&codex_dir, ctx)?;

    if removed.is_empty() {
        println!("RTK was not installed for Codex CLI (nothing to remove)");
    } else {
        let header = if dry_run {
            "[dry-run] would uninstall RTK for Codex CLI:"
        } else {
            "RTK uninstalled for Codex CLI:"
        };
        println!("{}", header);
        for item in removed {
            println!("  - {}", item);

View on GitHub (pinned to d977e1c316)

Solutions

  1. Run `rtk uninstall --global --codex`
  2. If a project AGENTS.md contains RTK instructions you added, remove that block manually

Example fix

# before
rtk uninstall --codex

# after
rtk uninstall --global --codex
Defensive patterns

Strategy: validation

Validate before calling

# bash: codex uninstall always needs --global
rtk uninstall --global --codex --dry-run   # preview removals first

Prevention

When it happens

Trigger: `rtk uninstall --codex` without `--global` — uninstall_codex at src/hooks/init.rs:876.

Common situations: Repos that keep their own AGENTS.md; users assuming uninstall touches a project file that rtk never wrote.

Related errors


AI-assisted analysis of rtk-ai/rtk@d977e1c316 (2026-08-16). Data as JSON: /api/errors/9ba5c1a571d7ee32. Report an issue: GitHub.