xai-org/grok-build · error

Cannot apply this fix without confirmation. Run it in an int

Error message

Cannot apply this fix without confirmation. Run it in an interactive terminal or add `--yes`.

What it means

`apply_fix_plan` previews the fix, then requires confirmation. When `--yes` was not passed and stdin is not a terminal, it cannot safely prompt, so it bails before making any change rather than applying a fix without explicit consent.

Source

Thrown at crates/codegen/xai-grok-pager/src/doctor_cmd/mod.rs:148

    );
    let request = crate::diagnostics::FixRequest::from_environment(id)?;
    let plan = crate::diagnostics::plan_fix(request, &report, &terminal)?;
    apply_fix_plan(args, stdin_is_terminal, input, writer, &terminal, plan)
}

fn apply_fix_plan(
    args: FixArgs,
    stdin_is_terminal: bool,
    input: &mut impl std::io::BufRead,
    writer: &mut impl Write,
    terminal: &crate::terminal::TerminalContext,
    plan: FixPlan,
) -> Result<()> {
    write_fix_preview(&plan, writer)?;

    if !args.yes {
        if !stdin_is_terminal {
            anyhow::bail!(
                "Cannot apply this fix without confirmation. Run it in an interactive terminal or add `--yes`."
            );
        }
        write!(writer, "\nApply this fix? [y/N] ")?;
        writer.flush()?;
        let mut answer = String::new();
        input.read_line(&mut answer)?;
        if !matches!(answer.trim().to_ascii_lowercase().as_str(), "y" | "yes") {
            writeln!(writer, "Fix cancelled.")?;
            return Ok(());
        }
    }

    let outcome = crate::diagnostics::apply_fix(plan)?;
    if outcome.activation() == FixActivation::SatisfiedNow {
        // Use the shell stored on the outcome (from planning), not `$SHELL`.
        // `$SHELL` may be missing or no longer match the shell the plan targeted.
        let post_report = crate::diagnostics::configured_report(

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Add `--yes` to the doctor fix command to confirm non-interactively.
  2. Run the command in an interactive terminal so the [y/N] prompt can be answered.
  3. In CI, explicitly opt in: `grok doctor <fix> --yes` after reviewing the preview.

Example fix

// before
grok doctor fix-config < /dev/null
// after
grok doctor fix-config --yes
Defensive patterns

Strategy: validation

Validate before calling

let interactive = std::io::stdin().is_terminal();
if !interactive && !args.yes {
    eprintln!("Non-interactive run: add --yes to confirm the doctor fix.");
    std::process::exit(1);
}

Try / catch

if let Err(e) = doctor_fix(args) {
    if e.to_string().contains("without confirmation") {
        eprintln!("Re-run with --yes (after reviewing the preview) or in a TTY.");
    } else { return Err(e); }
}

Prevention

When it happens

Trigger: Running a `doctor` fix with `args.yes == false` while `stdin_is_terminal == false` — e.g. piping input, running under CI, or invoking through a non-TTY wrapper. Reached from `run_fix` and covered by `non_tty_without_yes_fails_safely_before_write` and `decline_is_success_and_does_not_write`.

Common situations: Automating doctor fixes in CI without `--yes`; piping the command (`echo | grok doctor fix ...`); running inside a daemon/script executor with no TTY.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/e847fe76e4f0c6f9. Report an issue: GitHub.