rtk-ai/rtk · error

consent requires interactive terminal — cannot enable…

Error message

consent requires interactive terminal — cannot enable telemetry in piped mode

What it means

Enabling RTK telemetry requires explicit, informed consent typed by a human. `run_enable` therefore refuses to run when stdin is not a TTY (`io::stdin().is_terminal()` is false), because a piped or scripted invocation cannot provide genuine interactive consent for anonymous usage-data collection.

Solutions

  1. Run the enable command in a real interactive terminal (no pipes/redirects on stdin).
  2. Enable telemetry by setting the relevant config/env value directly (e.g. the telemetry opt-in key in rtk's config file or env var) instead of going through the interactive consent flow.
  3. If automation is required, skip telemetry entirely or use a config-management step that writes the consent flag yourself, acknowledging the consent policy.

Example fix

// before (script)
echo "y" | rtk telemetry enable

// after
# run interactively once:
rtk telemetry enable
# or set config directly:
rtk config set telemetry.enabled true
Defensive patterns

Strategy: fallback

Validate before calling

use std::io::IsTerminal;
if !std::io::stdin().is_terminal() {
    eprintln!("skipping `rtk telemetry enable`: requires interactive terminal");
    return Ok(());
}

Try / catch

match rtk_telemetry_enable().err() {
    Some(e) if e.to_string().contains("interactive terminal") => {
        eprintln!("telemetry enable must be run interactively; skipping");
    }
    _ => {}
}

Prevention

When it happens

Trigger: Running `rtk telemetry enable` (or whatever routes to run_enable) with stdin piped or redirected, e.g. `echo y | rtk telemetry enable`, inside CI scripts, non-interactive shells, docker exec without -t, or from another program spawning rtk without a TTY.

Common situations: Automating RTK setup in dotfiles or CI where a user tries to pre-answer the consent prompt; running inside containers or IDE terminals without a TTY; wrapping rtk commands in scripts that pipe stdin.

Related errors


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

Appendix: source

Thrown at src/core/telemetry_cmd.rs:155

            env_override,
            config.telemetry.enabled,
            config.telemetry.consent_given,
            hash.as_deref(),
        )
    );

    println!();
    println!("Data controller: RTK AI Labs, contact@rtk-ai.app");
    println!("Details: https://github.com/rtk-ai/rtk/blob/master/docs/TELEMETRY.md");

    Ok(())
}

fn run_enable() -> Result<()> {
    use std::io::{self, BufRead, IsTerminal};

    if !io::stdin().is_terminal() {
        anyhow::bail!(
            "consent requires interactive terminal — cannot enable telemetry in piped mode"
        );
    }

    eprintln!("RTK collects anonymous usage metrics once per day to improve filters.");
    eprintln!();
    eprintln!("  What:    command names (not arguments), token savings, OS, version");
    eprintln!("  Who:     RTK AI Labs, contact@rtk-ai.app");
    eprintln!("  Details: https://github.com/rtk-ai/rtk/blob/master/docs/TELEMETRY.md");
    eprintln!();
    eprint!("Enable anonymous telemetry? [y/N] ");

    let stdin = io::stdin();
    let mut line = String::new();
    stdin
        .lock()
        .read_line(&mut line)
        .context("Failed to read user input")?;

View on GitHub (pinned to 0924356b4c)