gitbutlerapp/gitbutler · error
Could not determine authentication method
Error message
Could not determine authentication method
What it means
Raised in `gitlab_auth` (crates/but/src/command/config.rs:953) when the interactive prompt for choosing a GitLab authentication method (PAT or Self-Hosted) yields no selection — `prompt_select(...)` returned `None`.
Solutions
- Re-run the command in an interactive terminal and choose PAT or Self-Hosted
- Configure the GitLab token non-interactively (config file or environment) if scripting
- Check terminal support for the interactive prompt (raw-mode/TTY) and TERM settings
- If self-hosted, verify you intend the Self-Hosted option and complete that sub-flow
Example fix
// before but config forge auth < /dev/null # EOF at prompt // after but config forge auth # interactively select "Personal Access Token"
Defensive patterns
Strategy: try-catch
Validate before calling
use std::io::IsTerminal;
if !std::io::stdin().is_terminal() {
return Err("GitLab auth prompt requires a TTY; supply a PAT via config instead");
} Try / catch
match gitlab_auth(input).await {
Err(e) if e.to_string().contains("Could not determine authentication method") => eprintln!("select PAT or Self-Hosted at the prompt"),
other => other,
} Prevention
- Answer the method prompt rather than aborting it
- Configure GitLab tokens non-interactively in CI
- Verify terminal raw-mode support before running prompts
When it happens
Trigger: During `gitlab_auth`, the user aborts the method prompt or stdin is not interactive/EOF, so no `AuthMethod` is returned and the `ok_or_else` fires.
Common situations: Running the config command through a script or CI without a TTY; pressing Ctrl+C/Esc at the prompt; terminal emulators that don't support the select prompt.
Understand the failure class
Background: "Must pass :limit option" / "Missing required option" — required option errors explained — this error's family across 41 libraries.
- Authentication and authorization failures — expired tokens, bad credentials, and missing scopes.
Related errors
- Known account is not correctly authenticated. Run
- No authenticated GitLab users found.\nRun 'but config forge…
- Authorization process aborted by user.
- Could not determine which forge provider to authenticate…
- ForgeNotAuthenticated
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/4cbd375015d1e95e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/config.rs:953
match method {
AuthMethod::Pat => "Personal Access Token (PAT)".to_string(),
AuthMethod::SelfHosted => "Self-Hosted GitLab".to_string(),
}
}
}
let mut input = out
.prepare_for_terminal_input()
.context("Human input required - run this in a terminal")?;
let auth_methods = nonempty::nonempty![
("Personal Access Token (PAT)", AuthMethod::Pat),
("Self-Hosted GitLab", AuthMethod::SelfHosted)
];
let selected_method = input
.prompt_select("Select an authentication method", &auth_methods)?
.cloned()
.ok_or_else(|| anyhow::anyhow!("Could not determine authentication method"))?;
match selected_method {
AuthMethod::Pat => gitlab_pat(input).await,
AuthMethod::SelfHosted => gitlab_self_hosted(input).await,
}
}
/// Authenticate with GitLab using a Personal Access Token (PAT)
async fn gitlab_pat(mut inout: InputOutputChannel<'_>) -> Result<()> {
use but_gitlab::AuthStatusResponse;
let input = inout
.prompt_secret("Please enter your GitLab Personal Access Token (PAT) and hit enter:")?
.context("No PAT provided. Aborting authentication.")?;
let AuthStatusResponse { username, .. } = but_api::gitlab::store_gitlab_pat(input)
.await
.map_err(|err| err.context("Authentication failed"))?;View on GitHub (pinned to 58e5313667)