gitbutlerapp/gitbutler · error
Could not determine selected AI provider
Error message
Could not determine selected AI provider
What it means
`but config ai` (interactive AI provider setup) asks the user to pick an LLM provider via `prompt_select` and clones the chosen item. If the prompt returns `None` — no selection made — the code raises this anyhow error because provider selection is required to continue configuration.
Solutions
- Run `but config ai` in an interactive terminal and complete the provider selection
- Set the provider non-interactively instead (e.g. via git config keys the CLI reads) if automation is required
- Fix terminal environment (TERM type, pty allocation) if the select UI cannot receive input
- Abort gracefully is not supported here; choose any provider then configure keys to skip later prompts
Example fix
// before: non-interactive invocation but config ai < /dev/null # Error: Could not determine selected AI provider // after: run in a TTY and select a provider from the list but config ai
Defensive patterns
Strategy: try-catch
Validate before calling
if [ ! -t 0 ]; then echo "but config ai requires a TTY"; exit 1; fi
Try / catch
match result {
Err(e) if e.to_string().contains("Could not determine selected AI provider") => {
eprintln!("AI provider selection was aborted; config unchanged.");
}
r => r?,
} Prevention
- Run `but config ai` only in interactive shells
- Configure AI provider via git config / env vars for automation
- Complete the selection instead of cancelling mid-prompt
When it happens
Trigger: Running `but config ai` and cancelling/aborting the provider selection prompt, or running where the select prompt cannot deliver a choice (non-TTY stdin, broken terminal input), so `.cloned()` yields None.
Common situations: Non-interactive shells or CI running `but config ai`; user pressing Esc/Ctrl-C at the provider list; terminals where arrow-key select UI fails (dumb TERM, limited pty).
Understand the failure class
Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.
Related errors
- Could not determine Anthropic credential source
- Could not determine OpenAI credential source
- Could not determine selected review template
- Could not determine which accounts to delete
- Setup required: - run `but setup` to configure the project
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/675f5225b8de32da.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/config.rs:1548
scope: AiScope,
) -> Result<()> {
let t = theme::get();
let mut inout = out
.prepare_for_terminal_input()
.context("Human input required - run this in a terminal")?;
let providers = nonempty::nonempty![
("OpenAI", LLMProviderKind::OpenAi),
("Anthropic", LLMProviderKind::Anthropic),
("Ollama", LLMProviderKind::Ollama),
("LM Studio", LLMProviderKind::LMStudio),
("OpenRouter", LLMProviderKind::OpenRouter)
];
let provider = inout
.prompt_select("Select an AI provider", &providers)?
.cloned()
.ok_or_else(|| anyhow::anyhow!("Could not determine selected AI provider"))?;
match provider {
LLMProviderKind::OpenAi => {
let key_options = nonempty::nonempty![
("Use GitButler API", AiKeyOption::ButlerApi),
("Bring your own key", AiKeyOption::BringYourOwn)
];
let key_option = inout
.prompt_select("Select OpenAI credential source", &key_options)?
.copied()
.ok_or_else(|| anyhow::anyhow!("Could not determine OpenAI credential source"))?;
let model = inout.prompt("Preferred OpenAI model (leave empty for default):")?;
let endpoint = inout.prompt("Custom endpoint URL (optional):")?;
let secret = if matches!(key_option, AiKeyOption::BringYourOwn) {
Some(
inoutView on GitHub (pinned to 58e5313667)