{"record":{"id":"f87b3ff0588db251","repo":"git-ecosystem/git-credential-manager","slug":"cannot-prompt-because-terminal-prompts-have-been-d","errorCode":null,"errorMessage":"Cannot prompt because terminal prompts have been disabled.","messagePattern":"Cannot prompt because terminal prompts have been disabled\\.","errorType":"exception","errorClass":"Trace2InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Core/Authentication/AuthenticationBase.cs","lineNumber":114,"sourceCode":"                throw new Trace2InvalidOperationException(Context.Trace2, \"Cannot prompt because user interactivity has been disabled.\");\n            }\n        }\n\n        protected void ThrowIfGuiPromptsDisabled()\n        {\n            if (!Context.Settings.IsGuiPromptsEnabled)\n            {\n                Context.Trace.WriteLine($\"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; GUI prompts have been disabled.\");\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Cannot show prompt because GUI prompts have been disabled.\");\n            }\n        }\n\n        protected void ThrowIfTerminalPromptsDisabled()\n        {\n            if (!Context.Settings.IsTerminalPromptsEnabled)\n            {\n                Context.Trace.WriteLine($\"{Constants.EnvironmentVariables.GitTerminalPrompts} is 0; terminal prompts have been disabled.\");\n                throw new Trace2InvalidOperationException(Context.Trace2, \"Cannot prompt because terminal prompts have been disabled.\");\n            }\n        }\n        \n        protected void ThrowIfWindowCancelled(WindowViewModel viewModel)\n        {\n            if (!viewModel.WindowResult)\n            {\n                throw new OperationCanceledException(\"User cancelled dialog.\");\n            }\n        }\n        \n        protected IntPtr GetParentWindowHandle()\n        {\n            if (int.TryParse(Context.Settings.ParentWindowId, out int id))\n            {\n                return new IntPtr(id);\n            }\n","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/git-ecosystem/git-credential-manager/blob/e8ce762cd04b4100ae637b5fbf39ef9d0a96561e/src/Core/Authentication/AuthenticationBase.cs#L96-L132","documentation":"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.","triggerScenarios":"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).","commonSituations":"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.","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"],"exampleFix":"// before (CI script)\nexport GIT_TERMINAL_PROMPT=0\ngit clone https://github.com/org/repo.git\n// after\nexport GIT_TERMINAL_PROMPT=1\ngit clone https://github.com/org/repo.git\n# or keep prompts disabled but configure a helper so prompting is never needed","handlingStrategy":"validation","validationCode":"if (Environment.GetEnvironmentVariable(\"GIT_TERMINAL_PROMPT\") == \"0\" && !Console.IsOutputRedirected)\n    throw new InvalidOperationException(\"Terminal prompts disabled; configure a credential helper or supply credentials non-interactively.\");","typeGuard":"bool CanPrompt() => Environment.GetEnvironmentVariable(\"GIT_TERMINAL_PROMPT\") != \"0\";","tryCatchPattern":"try { /* credential acquisition */ }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"terminal prompts have been disabled\")) { /* fall back to token/helper-based auth */ }","preventionTips":["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"],"tags":["terminal","prompts-disabled","git","non-interactive"],"backgroundTag":"prompts-disabled","analyzedSha":"e8ce762cd04b4100ae637b5fbf39ef9d0a96561e","analyzedAt":"2026-09-11T17:15:08.753Z","contentChangedAt":"2026-09-11T17:15:08.753Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}