rtk-ai/rtk · error

at least one of install_claude or install_opencode must be t

Error message

at least one of install_claude or install_opencode must be true

What it means

In rtk init's non-codex branch, the match over install flags requires at least one of the Claude or OpenCode install targets. If none is selected and Cursor was also not requested, run() bail!s with this internal-style message. It guards against a no-op `rtk init` invocation that would otherwise silently do nothing.

Source

Thrown at src/hooks/init.rs:327

        if install_windsurf {
            run_windsurf_mode(ctx)?;
        } else if install_cline {
            run_cline_mode(ctx)?;
        } else {
            // Mode selection (Claude Code / OpenCode)
            match (install_claude, install_opencode, claude_md, hook_only) {
                (false, true, _, _) => run_opencode_only_mode(ctx)?,
                (true, opencode, true, _) => run_claude_md_mode(global, opencode, ctx)?,
                (true, opencode, false, true) => {
                    run_hook_only_mode(global, patch_mode, opencode, ctx)?
                }
                (true, opencode, false, false) => {
                    run_default_mode(global, patch_mode, opencode, ctx)?
                }
                (false, false, _, _) => {
                    if !install_cursor {
                        anyhow::bail!(
                            "at least one of install_claude or install_opencode must be true"
                        )
                    }
                }
            }

            // Cursor hooks (additive, installed alongside Claude Code)
            if install_cursor {
                install_cursor_hooks(ctx)?;
            }
        }
    }

    if !dry_run {
        prompt_telemetry_consent()?;
        // Best-effort: unconditionally re-run tracking-DB schema migrations during
        // install/upgrade (bypassing the `user_version` gate `Tracker::new()` uses
        // on its hot path). This both pre-warms the schema so the first PreToolUse

View on GitHub (pinned to 36788f6bd4)

Solutions

  1. Pass an explicit target: `rtk init` defaults aside, use `rtk init -g --opencode`, `rtk init --agent cursor`, or the default Claude mode flag
  2. Check `rtk init --help` for the correct flag spelling for your target agent
  3. If you wanted Codex mode, use `rtk init -g --codex` instead

Example fix

// before
rtk init -g
// after
rtk init -g --opencode
Defensive patterns

Strategy: validation

Validate before calling

const args = process.argv.slice(2);
const hasTarget = ['--codex','--opencode','--agent','--claude'].some(f => args.includes(f));
if (args[0] === 'init' && !hasTarget) {
  throw new Error('rtk init needs a target: --codex, --opencode, --agent <x>, or default Claude mode');
}

Try / catch

try {
  execFileSync('rtk', ['init', '-g', '--opencode'], { stdio: 'inherit' });
} catch (e) {
  if (String(e.stderr).includes('at least one of install_claude or install_opencode')) {
    console.error('No install target selected; add a mode/agent flag.');
  }
  throw e;
}

Prevention

When it happens

Trigger: Running `rtk init -g` (or `rtk init`) with no mode/agent flags: install_claude=false, install_opencode=false, and install_cursor=false, hitting the `(false, false, _, _)` match arm.

Common situations: Users assuming bare `rtk init` has sensible defaults; scripts that strip flags dynamically and end up with an empty invocation; typos in agent names that disable the intended flag.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


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