gitbutlerapp/gitbutler · error

Interactive setup requires a terminal. Use `but agent setup…

Error message

Interactive setup requires a terminal. Use `but agent setup --print` to print the default instructions without modifying files.

What it means

`but agent setup` without --print runs an interactive wizard, which requires a TTY. When stdout is not promptable (piped, redirected, or run in CI), the command refuses to run and suggests the non-interactive `--print` mode.

Solutions

  1. Use `but agent setup --print` to print default instructions without modifying files.
  2. Allocate a TTY (e.g. run in a real terminal, or use `script -qec 'but agent setup'` on Linux).
  3. Skip the wizard and configure the agent files manually in non-interactive environments.

Example fix

// before (fails in CI)
but agent setup
// after
but agent setup --print
Defensive patterns

Strategy: try-catch

Validate before calling

if (!process.stdout.isTTY && cmd === 'but agent setup' && !args.includes('--print')) {
  cmd = 'but agent setup --print';
}

Try / catch

try {
  execSync('but agent setup', { stdio: 'inherit' });
} catch (err) {
  if (String(err.message).includes('Interactive setup requires a terminal')) {
    execSync('but agent setup --print', { stdio: 'inherit' });
  } else {
    throw err;
  }
}

Prevention

When it happens

Trigger: Running `but agent setup` (no --print flag) when out.can_prompt() is false: piping output, redirecting to a file, running under CI, or in a non-interactive shell.

Common situations: CI pipelines or Docker containers without a TTY; scripted setup attempts piping `but agent setup`; editors' embedded terminals without interactive stdin.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/a4392d247b3b5a69. Report an issue: GitHub.

Appendix: source

Thrown at crates/but/src/command/agent/mod.rs:81

    }
}

fn setup(
    current_dir: &Path,
    out: &mut OutputChannel,
    print_only: bool,
    skill_layout: SkillLayout,
) -> Result<CommandOutcome> {
    if print_only {
        let default_policy = render_managed_policy_block(&WizardAnswers::default());
        print_policy(out, &default_policy)?;
        return Ok(CommandOutcome::AgentSetupPrintOnly);
    }

    let repo = discover_repo(current_dir);

    if !out.can_prompt() {
        anyhow::bail!(
            "Interactive setup requires a terminal. Use `but agent setup --print` to print the default instructions without modifying files."
        );
    }

    let mut input = out
        .prepare_for_terminal_input()
        .context("Interactive setup requires a terminal.")?;

    let plan = collect_plan(&mut input, repo)?;
    drop(input);

    match plan {
        Some(plan) => apply_plan(out, current_dir, &plan, skill_layout),
        None => {
            print_cancelled(out)?;
            Ok(CommandOutcome::AgentSetupCancelled)
        }
    }

View on GitHub (pinned to 58e5313667)