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

Cannot prompt because user interactivity has been disabled.

Error message

Cannot prompt because user interactivity has been disabled.

What it means

ThrowIfUserInteractionDisabled checks the GCM_INTERACTIVE environment variable / credential.interactive Git config. If set to false/never, any code path that would prompt the user throws Trace2InvalidOperationException because prompting is explicitly forbidden by configuration.

Solutions

  1. Pre-provision credentials non-interactively (e.g. `git credential approve` with a PAT, or embed token in remote URL / credential store).
  2. Remove the restriction: unset GCM_INTERACTIVE or set credential.interactive=true if prompting is acceptable.
  3. Ensure a valid cached credential exists in the configured store (credential.helper / GCM cache) before running non-interactive.

Example fix

// before: non-interactive with no cached credential -> throws
export GCM_INTERACTIVE=never
git pull
// after: pre-seed the credential
printf "protocol=https\nhost=bitbucket.example.com\nusername=user\npassword=TOKEN\n" | git credential approve
export GCM_INTERACTIVE=never
git pull
Defensive patterns

Strategy: validation

Validate before calling

#!/bin/sh
if [ "$GCM_INTERACTIVE" = "never" ] || [ "$(git config --get credential.interactive)" = "never" ]; then
  printf "protocol=https\nhost=bitbucket.example.com\n" | git credential fill >/dev/null 2>&1 \
    || { echo "No cached credential and prompting disabled"; exit 1; }
fi

Try / catch

try { var cred = await auth.GetCredentialAsync(input); } catch (InvalidOperationException ex) when (ex.Message.Contains("user interactivity has been disabled")) { /* fail fast and instruct CI to pre-provision credentials */ }

Prevention

When it happens

Trigger: Calling a credential flow that needs to show a prompt (UI dialog or terminal question) while GCM_INTERACTIVE=never (env) or credential.interactive=false/never (Git config) is in effect.

Common situations: CI/CD pipelines or headless servers where GCM_INTERACTIVE=never was set but no cached credential exists; Docker builds running git fetch; scripts that disable prompting yet still expect fresh logins.

Related errors


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

Appendix: source

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

                }

                throw new Trace2Exception(Context.Trace2, $"helper error ({exitCode}): {errorMessage}");
            }

            return resultDict;
        }

        protected void ThrowIfUserInteractionDisabled()
        {
            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.");

View on GitHub (pinned to e8ce762cd0)