gitbutlerapp/gitbutler · error

Could not determine which accounts to delete

Error message

Could not determine which accounts to delete

What it means

In `but config forge-forget`, the interactive multi-select prompt (`prompt_multi_select`) returned `None` instead of a selection list. The `but` CLI treats a non-answer (typically a cancelled or non-interactive prompt) as an unrecoverable condition and raises this anyhow error, since it cannot proceed to delete accounts without knowing which ones to forget.

Solutions

  1. Run the command in an interactive terminal with a working TTY so the multi-select can render
  2. Do not cancel the prompt; select zero accounts and confirm to get the graceful 'No accounts were selected' path instead
  3. Pipe no input is unsupported; use a pty wrapper (e.g. `script -c` or expect) if automation is needed
  4. Verify terminal supports the interactive prompt library (correct TERM, no broken crossterm input)

Example fix

// before: running non-interactively fails
echo | but config forge-forget  # Error: Could not determine which accounts to delete

// after: run interactively, or explicitly decline via empty selection
but config forge-forget   # in a real TTY; press Enter with none selected to exit cleanly
Defensive patterns

Strategy: try-catch

Validate before calling

// shell: ensure interactive TTY before invoking
if [ ! -t 0 ]; then echo "refusing: requires interactive terminal"; exit 1; fi

Try / catch

match but::config_forget_accounts() {
    Err(e) if e.to_string().contains("Could not determine which accounts") => {
        eprintln!("Prompt was cancelled or non-interactive; no accounts deleted.");
    }
    r => r?,
}

Prevention

When it happens

Trigger: Running `but config forge-forget` in an environment where the multi-select prompt cannot return a value: stdin is not a TTY (piped/ci), the user aborts the prompt (Ctrl-C/Esc handled as None), or the prompt backend fails to render and yields None. The error fires before the empty-selection check.

Common situations: Running the command from scripts, CI, or non-interactive shells where no terminal prompt UI is available; terminal multiplexer or unusual TERM settings breaking the interactive picker; users cancelling the dialog expecting a graceful exit but getting a hard error.

Understand the failure class

Background: "no subcommand specified" and "... is required": CLI errors when a required argument is missing — this error's family across 13 libraries.

Related errors


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

Appendix: source

Thrown at crates/but/src/command/config.rs:1322

        }
        _ => {
            // Multiple accounts: prompt user to select
            let Some(mut input) = out.prepare_for_terminal_input() else {
                anyhow::bail!("Username ambiguous, got {accounts_to_delete:?}");
            };
            let account_options = accounts_to_delete
                .into_iter()
                .map(|account| (account.to_string(), account))
                .collect::<Vec<_>>();
            let account_options = nonempty::NonEmpty::from_vec(account_options)
                .context("No accounts available to forget")?;

            let selected_accounts = input
                .prompt_multi_select(
                    "Which of the following accounts do you want to forget?",
                    &account_options,
                )?
                .ok_or_else(|| anyhow::anyhow!("Could not determine which accounts to delete"))?;

            if selected_accounts.is_empty() {
                writeln!(input, "No accounts were selected to forget.")?;
                return Ok(());
            }

            for account in selected_accounts {
                forget_account(account)?;
                writeln!(input, "Forgot forge account '{account}'")?;
            }
        }
    }

    Ok(())
}

fn ai_config_with_repo(
    ctx: &mut Context,

View on GitHub (pinned to 58e5313667)