rtk-ai/rtk · error

Uninstall only works with --global flag. For local…

Error message

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

What it means

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.

Solutions

  1. Run `rtk uninstall -g --codex` (add --dry-run to preview removals)
  2. For project-local AGENTS.md RTK blocks, delete the section manually
  3. Verify removal afterwards by checking the global Codex directory no longer contains the rtk notify plugin

Example fix

// before
rtk uninstall --codex
// after
rtk uninstall -g --codex
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2);
if (args[0] === 'uninstall' && args.includes('--codex')
    && !args.includes('-g') && !args.includes('--global')) {
  throw new Error('Codex uninstall is global-only; add -g');
}

Try / catch

try {
  execFileSync('rtk', ['uninstall', '-g', '--codex', '--dry-run'], { stdio: 'inherit' });
} catch (e) {
  if (String(e.stderr).includes('global flag')) {
    console.error('Codex uninstall requires -g; local AGENTS.md edits are manual.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `rtk uninstall --codex` without `-g`/`--global`. Fires at the top of uninstall_codex() before resolve_codex_dir().

Common situations: Users who ran `rtk init --codex -g` and later attempt a local uninstall; cleanup scripts parameterized for local scope.

Related errors


AI-assisted analysis of rtk-ai/rtk@36788f6bd4 (2026-09-03). Data as JSON: /api/errors/9ba5c1a571d7ee32. Report an issue: GitHub.

Appendix: source

Thrown at src/hooks/init.rs:892

        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 36788f6bd4)