git-ecosystem/git-credential-manager · error · Trace2InvalidOperationException

Cannot show prompt because GUI prompts have been disabled.

Error message

Cannot show prompt because GUI prompts have been disabled.

What it means

ThrowIfGuiPromptsDisabled checks Context.Settings.IsGuiPromptsEnabled, driven by GIT_TERMINAL_PROMPT=0 / GCM's GUI prompt settings. When GUI prompts are disabled but the flow tries to show a GUI authentication dialog, it throws Trace2InvalidOperationException.

Solutions

  1. Enable GUI prompts (unset GIT_TERMINAL_PROMPT=0) or switch to a non-GUI authentication mode (PAT via credential store, basic auth).
  2. Use a credential helper flow that does not need a display: pre-approve a token with `git credential approve`.
  3. In SSH/WSL, set up display forwarding or use terminal-prompt capable flows.

Example fix

// before
export GIT_TERMINAL_PROMPT=0
git pull   # GUI prompt required -> throws
// after: use PAT provisioned non-interactively
printf "protocol=https\nhost=bitbucket.example.com\nusername=user\npassword=TOKEN\n" | git credential approve
export GIT_TERMINAL_PROMPT=0
git pull
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
if [ "$GIT_TERMINAL_PROMPT" = "0" ]; then
  printf "protocol=https\nhost=bitbucket.example.com\n" | git credential fill >/dev/null 2>&1 \
    || { echo "GUI prompts disabled and no cached credential"; exit 1; }
fi

Try / catch

try { var cred = await auth.GetCredentialAsync(input); } catch (InvalidOperationException ex) when (ex.Message.Contains("GUI prompts have been disabled")) { /* switch to PAT/token-based flow or enable prompts */ }

Prevention

When it happens

Trigger: An authentication flow that requires a GUI dialog runs while GIT_TERMINAL_PROMPT=0 (or equivalent GUI-prompts-off config) is set — commonly in CI or SSH sessions without a display.

Common situations: CI runners exporting GIT_TERMINAL_PROMPT=0 to avoid hangs; WSL/SSH without X forwarding attempting OAuth browser/GUI flows; automation that disables prompts but invokes a GUI-based provider flow.

Related errors


AI-assisted analysis of git-ecosystem/git-credential-manager@e8ce762cd0 (2026-09-11). Data as JSON: /api/errors/80c1075d03042fb9. Report an issue: GitHub.

Appendix: source

Thrown at src/Core/Authentication/AuthenticationBase.cs:105

        {
            if (!Context.Settings.IsInteractionAllowed)
            {
                string envName = Constants.EnvironmentVariables.GcmInteractive;
                string cfgName = string.Format("{0}.{1}",
                    Constants.GitConfiguration.Credential.SectionName,
                    Constants.GitConfiguration.Credential.Interactive);

                Context.Trace.WriteLine($"{envName} / {cfgName} is false/never; user interactivity has been disabled.");
                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.");
            }

View on GitHub (pinned to e8ce762cd0)