rtk-ai/rtk · error

Antigravity is project-scoped. Use: rtk init --agent…

Error message

Antigravity is project-scoped. Use: rtk init --agent antigravity

What it means

rtk's `rtk init --agent antigravity` supports only project-scoped installation. When `--global` is passed, src/main.rs:2451 bails out with `anyhow::bail!` because Antigravity's hook integration has no global configuration path; the library fails fast rather than writing an unsupported global config.

Solutions

  1. Run `rtk init --agent antigravity` without `--global` from the project root
  2. Repeat the project-level init in each repository that needs Antigravity hooks
  3. Check `rtk init --help` to see which agents accept `--global`

Example fix

// before
rtk init --agent antigravity --global
// after
rtk init --agent antigravity
Defensive patterns

Strategy: validation

Validate before calling

// shell guard before invoking rtk
case "$AGENT:$FLAGS" in antigravity:*--global*) echo "antigravity is project-scoped; drop --global"; exit 1;; esac

Try / catch

// Rust caller
if let Err(e) = rtk_init_agent(AgentTarget::Antigravity, global) {
    if e.to_string().contains("project-scoped") { return init_without_global(); }
    return Err(e.into());
}

Prevention

When it happens

Trigger: Running `rtk init --agent antigravity` together with the global flag (`--global`) in `src/main.rs`, so the `AgentTarget::Antigravity` branch sees `global == true`.

Common situations: Copy-pasting an init command from a globally-supported agent and swapping the agent name; automation that always passes `--global`; assuming all agent targets share the same scoping rules.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at src/main.rs:2451

                if global {
                    hooks::init::run_copilot_global(ctx)?;
                } else {
                    hooks::init::run_copilot(ctx)?;
                }
            } else if agent == Some(AgentTarget::Pi) {
                hooks::init::run_pi_mode_with_patch_mode(global, patch_mode, ctx)?
            } else if agent == Some(AgentTarget::Trae) {
                hooks::init::run_trae_mode(global, ctx)?
            } else if agent == Some(AgentTarget::Omp) {
                hooks::init::run_omp_mode_with_patch_mode(global, patch_mode, ctx)?
            } else if agent == Some(AgentTarget::Kilocode) {
                if global {
                    anyhow::bail!("Kilo Code is project-scoped. Use: rtk init --agent kilocode");
                }
                hooks::init::run_kilocode_mode(ctx)?;
            } else if agent == Some(AgentTarget::Antigravity) {
                if global {
                    anyhow::bail!(
                        "Antigravity is project-scoped. Use: rtk init --agent antigravity"
                    );
                }
                hooks::init::run_antigravity_mode(ctx)?;
            } else if agent == Some(AgentTarget::Kimi) {
                if global {
                    anyhow::bail!("Kimi AI is project-scoped. Use: rtk init --agent kimi");
                }
                hooks::init::run_kimi_mode(ctx)?;
            } else if agent == Some(AgentTarget::Hermes) {
                hooks::init::run_hermes_mode(ctx)?;
            } else if agent == Some(AgentTarget::Droid) {
                hooks::init::run_droid_mode(global, ctx)?;
            } else if agent == Some(AgentTarget::Vibe) {
                hooks::init::run_vibe_mode(global, hook_only, patch_mode, ctx)?;
            } else {
                let install_opencode = opencode;
                let install_claude = !opencode;

View on GitHub (pinned to 0924356b4c)