git-ecosystem/git-credential-manager · error · Trace2InvalidOperationException
Cannot prompt because terminal prompts have been disabled.
Error message
Cannot prompt because terminal prompts have been disabled.
What it means
This is GCM's guard against attempting interactive terminal prompts when prompting has been explicitly disabled. The GIT_TERMINAL_PROMPT environment variable set to 0 tells Git (and GCM) that no interactive input may be read from the terminal, so any credential acquisition path that would require prompting throws immediately.
Solutions
- Set GIT_TERMINAL_PROMPT=1 (or unset it) to allow terminal prompting
- Configure a credential helper or GUI so credentials are obtained without prompting
- Supply credentials non-interactively (e.g. GCM_USER/GCM_PASS, GCM_INTERACTIVE=never with stored creds, or a URL-embedded/pre-filled credential store)
- If running headless, pre-authenticate once so the credential is cached in the store
Example fix
// before (CI script) export GIT_TERMINAL_PROMPT=0 git clone https://github.com/org/repo.git // after export GIT_TERMINAL_PROMPT=1 git clone https://github.com/org/repo.git # or keep prompts disabled but configure a helper so prompting is never needed
Defensive patterns
Strategy: validation
Validate before calling
if (Environment.GetEnvironmentVariable("GIT_TERMINAL_PROMPT") == "0" && !Console.IsOutputRedirected)
throw new InvalidOperationException("Terminal prompts disabled; configure a credential helper or supply credentials non-interactively."); Type guard
bool CanPrompt() => Environment.GetEnvironmentVariable("GIT_TERMINAL_PROMPT") != "0"; Try / catch
try { /* credential acquisition */ }
catch (InvalidOperationException ex) when (ex.Message.Contains("terminal prompts have been disabled")) { /* fall back to token/helper-based auth */ } Prevention
- Set GIT_TERMINAL_PROMPT only when a non-interactive credential source exists
- Configure credential.helper in CI images before running git
- Use PAT/token env vars for headless runs
When it happens
Trigger: ThrowIfTerminalPromptsDisabled is called before showing a terminal prompt; it throws when Context.Settings.IsTerminalPromptsEnabled is false, i.e. GIT_TERMINAL_PROMPT=0 in the environment and the credential provider fell back to a terminal prompt (no GUI, no credential helper output, non-interactive session).
Common situations: Running git in CI or a headless server where GIT_TERMINAL_PROMPT=0 is set but no credential helper is configured; SSH sessions without a display; scripts that disabled prompts for safety but still expect GCM to obtain credentials some other way.
Related errors
- At least one AuthenticationModes must be supplied
- Cannot prompt because user interactivity has been disabled.
- Missing 'protocol' request argument
- Invalid 'protocol' request argument (cannot be empty)
- Missing 'host' request argument
AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11).
Data as JSON: /api/errors/f87b3ff0588db251.
Report an issue: GitHub.
Appendix: source
Thrown at src/Core/Authentication/AuthenticationBase.cs:114
throw new Trace2InvalidOperationException(Context.Trace2, "Cannot prompt because user interactivity has been disabled.");
}
}
protected void ThrowIfGuiPromptsDisabled()
{
if (!Context.Settings.IsGuiPromptsEnabled)
{
Context.Trace.WriteLine($"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; GUI prompts have been disabled.");
throw new Trace2InvalidOperationException(Context.Trace2, "Cannot show prompt because GUI prompts have been disabled.");
}
}
protected void ThrowIfTerminalPromptsDisabled()
{
if (!Context.Settings.IsTerminalPromptsEnabled)
{
Context.Trace.WriteLine($"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; terminal prompts have been disabled.");
throw new Trace2InvalidOperationException(Context.Trace2, "Cannot prompt because terminal prompts have been disabled.");
}
}
protected void ThrowIfWindowCancelled(WindowViewModel viewModel)
{
if (!viewModel.WindowResult)
{
throw new OperationCanceledException("User cancelled dialog.");
}
}
protected IntPtr GetParentWindowHandle()
{
if (int.TryParse(Context.Settings.ParentWindowId, out int id))
{
return new IntPtr(id);
}
View on GitHub (pinned to e8ce762cd0)