{"record":{"id":"a4392d247b3b5a69","repo":"gitbutlerapp/gitbutler","slug":"interactive-setup-requires-a-terminal-use-but-ag","errorCode":null,"errorMessage":"Interactive setup requires a terminal. Use `but agent setup --print` to print the default instructions without modifying files.","messagePattern":"Interactive setup requires a terminal\\. Use `but agent setup --print` to print the default instructions without modifying files\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/agent/mod.rs","lineNumber":81,"sourceCode":"    }\n}\n\nfn setup(\n    current_dir: &Path,\n    out: &mut OutputChannel,\n    print_only: bool,\n    skill_layout: SkillLayout,\n) -> Result<CommandOutcome> {\n    if print_only {\n        let default_policy = render_managed_policy_block(&WizardAnswers::default());\n        print_policy(out, &default_policy)?;\n        return Ok(CommandOutcome::AgentSetupPrintOnly);\n    }\n\n    let repo = discover_repo(current_dir);\n\n    if !out.can_prompt() {\n        anyhow::bail!(\n            \"Interactive setup requires a terminal. Use `but agent setup --print` to print the default instructions without modifying files.\"\n        );\n    }\n\n    let mut input = out\n        .prepare_for_terminal_input()\n        .context(\"Interactive setup requires a terminal.\")?;\n\n    let plan = collect_plan(&mut input, repo)?;\n    drop(input);\n\n    match plan {\n        Some(plan) => apply_plan(out, current_dir, &plan, skill_layout),\n        None => {\n            print_cancelled(out)?;\n            Ok(CommandOutcome::AgentSetupCancelled)\n        }\n    }","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/agent/mod.rs#L63-L99","documentation":"`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.","triggerScenarios":"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.","commonSituations":"CI pipelines or Docker containers without a TTY; scripted setup attempts piping `but agent setup`; editors' embedded terminals without interactive stdin.","solutions":["Use `but agent setup --print` to print default instructions without modifying files.","Allocate a TTY (e.g. run in a real terminal, or use `script -qec 'but agent setup'` on Linux).","Skip the wizard and configure the agent files manually in non-interactive environments."],"exampleFix":"// before (fails in CI)\nbut agent setup\n// after\nbut agent setup --print","handlingStrategy":"try-catch","validationCode":"if (!process.stdout.isTTY && cmd === 'but agent setup' && !args.includes('--print')) {\n  cmd = 'but agent setup --print';\n}","typeGuard":null,"tryCatchPattern":"try {\n  execSync('but agent setup', { stdio: 'inherit' });\n} catch (err) {\n  if (String(err.message).includes('Interactive setup requires a terminal')) {\n    execSync('but agent setup --print', { stdio: 'inherit' });\n  } else {\n    throw err;\n  }\n}","preventionTips":["Detect non-TTY environments (CI, Docker, pipes) before invoking interactive commands.","Default to --print in automation and reserve the wizard for human terminals.","Wrap interactive commands with a TTY check (process.stdout.isTTY or `test -t 1`)."],"tags":["cli","tty","interactive","non-interactive"],"backgroundTag":"missing-tty","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}