rtk-ai/rtk · error

Cursor uninstall only works with --global flag

Error message

Cursor uninstall only works with --global flag

What it means

Thrown by uninstall_with_patch_mode when Cursor hooks uninstall (`--cursor`) is requested without `--global`. Cursor hook removal operates exclusively on the global Cursor configuration, so a non-global uninstall path does not exist. This mirrors the install-side global-only rule for Cursor.

Solutions

  1. Re-run with the global flag: `rtk uninstall -g --cursor`.
  2. If unsure whether Cursor hooks exist, run the global uninstall in dry-run mode to list what would be removed.
  3. If only local project artifacts should be cleaned, drop `--cursor` and manually remove RTK entries from the project's CLAUDE.md instead.

Example fix

// before (shell)
rtk uninstall --cursor
// after (shell)
rtk uninstall -g --cursor
Defensive patterns

Strategy: try-catch

Validate before calling

# ensure the global flag is present for cursor uninstall
case " $* " in
  *" --cursor "*) [[ " $* " == *" -g "* || " $* " == *" --global "* ]] || set -- -g "$@";;
esac
rtk uninstall "$@"

Try / catch

if ! rtk uninstall --cursor 2>err.txt; then
  grep -q 'only works with --global' err.txt && rtk uninstall -g --cursor
fi

Prevention

When it happens

Trigger: Calling `rtk uninstall --cursor` (cursor=true, global=false). The bail fires in uninstall_with_patch_mode at src/hooks/init.rs:919-921 before remove_cursor_hooks is invoked.

Common situations: Cleaning up RTK after switching tools and running uninstall inside a repo without `-g`; scripting uninstall for all agents uniformly and forgetting Cursor requires global; running the same uninstall command that previously succeeded for claude-based hooks.

Understand the failure class

Background: "--flag is required" and "must specify" CLI errors: how missing-required-flag validation works and how to fix it — this error's family across 20 libraries.

Related errors


AI-assisted analysis of rtk-ai/rtk@0924356b4c (2026-09-19). Data as JSON: /api/errors/b4eab9f51bc32ec5. Report an issue: GitHub.

Appendix: source

Thrown at src/hooks/init.rs:920

    pi: bool,
    omp: bool,
    patch_mode: PatchMode,
    ctx: InitContext,
) -> Result<()> {
    let InitContext {
        verbose, dry_run, ..
    } = ctx;
    if codex {
        uninstall_codex(global, ctx)?;
        if dry_run {
            print_dry_run_footer();
        }
        return Ok(());
    }

    if cursor {
        if !global {
            anyhow::bail!("Cursor uninstall only works with --global flag");
        }
        let cursor_removed = remove_cursor_hooks(ctx).context("Failed to remove Cursor hooks")?;
        if !cursor_removed.is_empty() {
            let header = if dry_run {
                "[dry-run] would uninstall RTK (Cursor):"
            } else {
                "RTK uninstalled (Cursor):"
            };
            println!("{}", header);
            for item in &cursor_removed {
                println!("  - {}", item);
            }
            if !dry_run {
                println!("\nRestart Cursor to apply changes.");
            }
        } else {
            println!("RTK Cursor support was not installed (nothing to remove)");
        }

View on GitHub (pinned to 0924356b4c)