{"record":{"id":"bc32cf5c092e2336","repo":"spectreconsole/spectre.console","slug":"alternate-buffers-are-not-supported-since-your-ter","errorCode":null,"errorMessage":"Alternate buffers are not supported since your terminal does not support ANSI.","messagePattern":"Alternate buffers are not supported since your terminal does not support ANSI\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Spectre.Console/Extensions/AnsiConsoleExtensions.Screen.cs","lineNumber":19,"sourceCode":"namespace Spectre.Console;\n\n/// <summary>\n/// Contains extension methods for <see cref=\"IAnsiConsole\"/>.\n/// </summary>\npublic static partial class AnsiConsoleExtensions\n{\n    /// <summary>\n    /// Switches to an alternate screen buffer if the terminal supports it.\n    /// </summary>\n    /// <param name=\"console\">The console.</param>\n    /// <param name=\"action\">The action to execute within the alternate screen buffer.</param>\n    public static void AlternateScreen(this IAnsiConsole console, Action action)\n    {\n        ArgumentNullException.ThrowIfNull(console);\n\n        if (!console.Profile.Capabilities.Ansi)\n        {\n            throw new NotSupportedException(\"Alternate buffers are not supported since your terminal does not support ANSI.\");\n        }\n\n        if (!console.Profile.Capabilities.AlternateBuffer)\n        {\n            throw new NotSupportedException(\"Alternate buffers are not supported by your terminal.\");\n        }\n\n        // Switch to alternate screen\n        console.WriteAnsi(w =>\n        {\n            w.EnterAltScreen();\n            w.CursorHome();\n        });\n\n        try\n        {\n            // Execute custom action\n            action();","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/spectreconsole/spectre.console/blob/0acc92fada6c42f13984e79c2b5f3d993bdfb099/src/Spectre.Console/Extensions/AnsiConsoleExtensions.Screen.cs#L1-L37","documentation":"Thrown by the AlternateScreen extension when the console profile reports no ANSI support (Capabilities.Ansi is false). Alternate screen buffers are implemented with ANSI escape sequences, so without ANSI the feature is unavailable; this is a NotSupportedException, not a usage bug.","triggerScenarios":"Calling console.AlternateScreen(action) on a console whose Profile.Capabilities.Ansi is false.","commonSituations":"Output is redirected to a file/pipe so ANSI detection fails; running on a legacy Windows console with ANSI disabled; an explicitly configured AnsiSupport.No profile; CI/headless run where the terminal is not detected as ANSI-capable.","solutions":["Force ANSI on in settings: new AnsiConsoleSettings { Ansi = AnsiSupport.Yes } before creating the console","Only call AlternateScreen when console.Profile.Capabilities.Ansi is true","Redirect-aware: do not use AlternateScreen when Console.IsOutputRedirected","On Windows, enable a modern terminal (Windows Terminal) or virtual terminal processing"],"exampleFix":"// before\nvar settings = new AnsiConsoleSettings { Ansi = AnsiSupport.No };\nvar console = AnsiConsole.Create(settings);\nconsole.AlternateScreen(() => { }); // throws\n\n// after\nvar settings = new AnsiConsoleSettings { Ansi = AnsiSupport.Yes };\nvar console = AnsiConsole.Create(settings);\nconsole.AlternateScreen(() => { });","handlingStrategy":"type-guard","validationCode":"if (console.Profile.Capabilities.Ansi)\n{\n    console.AlternateScreen(() => Draw(console));\n}\nelse\n{\n    Draw(console); // fallback in main buffer\n}","typeGuard":"static bool SupportsAltScreen(IAnsiConsole c) =>\n    c.Profile.Capabilities.Ansi && c.Profile.Capabilities.AlternateBuffer;","tryCatchPattern":"try\n{\n    console.AlternateScreen(() => Draw(console));\n}\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"does not support ANSI\"))\n{\n    Draw(console); // fallback: redraw in the main buffer\n}","preventionTips":["Gate AlternateScreen behind a Capabilities.Ansi check","Set AnsiSupport.Yes when you know the target supports ANSI","Avoid AlternateScreen when Console.IsOutputRedirected is true"],"tags":["ansi","terminal-capabilities","alternate-buffer","configuration"],"backgroundTag":null,"analyzedSha":"0acc92fada6c42f13984e79c2b5f3d993bdfb099","analyzedAt":"2026-08-13T18:27:21.983Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}