Skip to content

ANSI color detection fails in PowerShell terminal launched through GitHub Desktop on Windows (Maven 3.10.1) #14018

Closed

Description

@hazendaz

Affected version

3.10.1

Bug description

Title

ANSI color detection fails in PowerShell terminal launched through GitHub Desktop on Windows (Maven 3.10.1)

Description

After upgrading to Maven 3.10.1, automatic ANSI color output no longer works in the PowerShell terminal launched through GitHub Desktop.

This appears to be related to the terminal detection changes introduced when JLine was removed in Maven 3.10.1.

I have isolated the issue to the absence of the WT_SESSION environment variable in the PowerShell process launched through GitHub Desktop.

Environment

  • OS: Windows 11 (latest available release)

  • Terminal: Windows Terminal

  • Shell: PowerShell 7.6

  • GitHub Desktop: 3.6.10

  • JDK: OpenJDK 27

  • Maven: 3.10.1

Steps to reproduce

  1. Launch a PowerShell terminal through GitHub Desktop.

  2. Run:

    mvn -version
  3. Observe that ANSI color output is disabled.

Diagnostics

The JVM correctly identifies the console as an interactive terminal:

System.out.println(System.console());
System.out.println(System.console().isTerminal());

Output:

java.io.ProxyingConsole@31221be2
true

The following environment variables are absent in the failing session:

  • WT_SESSION

  • WT_PROFILE_ID

  • TERM

  • TERM_PROGRAM

  • ConEmuANSI

  • ANSICON

However, when PowerShell is launched normally through Windows Terminal, both WT_SESSION and WT_PROFILE_ID are present.

Confirmed workaround

Setting WT_SESSION manually in the failing PowerShell session immediately restores automatic color detection:

$env:WT_SESSION = 'test'
mvn -version

Maven now produces colored output without requiring --color=always.

Additional testing

I tested the following environments on the same Windows 11 machine:

EnvironmentANSI color
Windows Terminal with PowerShell 5.1Works
Windows Terminal with PowerShell 7.6Works
PowerShell 7.6 launched through GitHub DesktopFails
Git BashWorks
Command PromptWorks
GitHub Desktop PowerShell with WT_SESSION manually definedWorks

Explicitly specifying --color=always also works in the failing environment.

Expected behavior

Maven should correctly identify ANSI-capable Windows terminal sessions without relying exclusively on the presence of specific environment variables.

In this case, the JVM already identifies the console as a valid terminal, but Maven subsequently applies additional Windows-specific environment checks that disable color.

Additional context

This regression was introduced as part of the JLine removal in Maven 3.10.1.

The current detection logic explicitly checks for WT_SESSION to identify Windows Terminal. However, processes launched through GitHub Desktop do not necessarily inherit this variable, even when the resulting PowerShell session is running in an ANSI-capable terminal.

Manually defining WT_SESSION confirms that this is the specific detection condition preventing automatic color output.

Would it be possible to improve Windows terminal detection so that ANSI-capable terminals are recognized without depending on WT_SESSION being present?

This should also be covered by Windows terminal detection tests, particularly for processes launched by other desktop applications.

Additional note: I also tested launching Command Prompt through GitHub Desktop and observed the same behavior. This confirms the issue is not specific to PowerShell, but affects other shells launched through GitHub Desktop as well.

Activity

  1. added
    bug
    on Nov 15, 2026
  2. added this to the 3.10.2 milestone on Nov 17, 2026
  3. cstamas commented on Nov 17, 2026

    @cstamas
    Member

    So to say, if Windows execution path includes the existing System.console().isTerminal() check (on Java 22+), we are fine?

  4. hazendaz commented on Nov 18, 2026

    @hazendaz
    ContributorAuthor

    After looking at your PR, I'm wondering if we can simplify this further.

    For Java 22+, why not simply trust Console.isTerminal()? In my environment (Java 27), it correctly returns true despite GitHub Desktop providing none of the environment variables currently used by Maven.

    Those variables clearly aren't required for ANSI output, and their absence shouldn't be interpreted as a lack of terminal support.

    For older Java versions, we'd obviously need a fallback since the API isn't available.

  5. cstamas commented on Nov 18, 2026

    @cstamas
    Member

    @hazendaz my only concern: if we rely solely on Console.isTerminal(), is there any chance to have Windows user see "garbled output" (ANSI codes non interpreted)? As IMHO even what 3.10.1 did was "good enough", and we just improved it. The reason why I went for Windows 11 is that according to Claude, on Win 10 ANSI interpretation was OFF by default and user had to enable it.... IMHO, non-colored readable output is better then non-colored unreadable output... I just want to be on safe side.

  6. hazendaz commented on Nov 18, 2026

    @hazendaz
    ContributorAuthor

    @cstamas What specific Windows 10 compatibility scenario are we trying to preserve that Maven 3.9 did not already handle? Up until mid last year I was using server copies of windows 10, color encoding was fine with those using powershell in same way. I ran the claude guideline through chatgpt, it had a different interpretation of that. But aside from what are there user reports that was a problem in 3.9?

  7. cstamas commented on Nov 18, 2026

    @cstamas
    Member

    Unsure did you follow latest changes, but Maven 3.9.x used today defunct jansi library, that was early in 3.10.x development replaced with Jline3 library. The issue with this change was that it introduced a huge, sensible and annoying lag at mvn startup, due loading native libraries (not to mention other, keep recurring issues, like quarantine of native code on macos, changing how new Java handles/allows natives, and so on). So, 3.10.1 went radical: it dropped JLine3 library, as "only for color logging" JLine3 was really a huge overkill (see PR explanation #13888 ).

    So, "worked with 3.9" does not means a lot, as 3.10.x now needs to somehow bring the closest possible coverage, without doing all the native hoops and loops, so goal is to remain lean and fast, as 3.10.1 is, and cover most we can. On the flipside, I would remain conservative, as while every major OS is well covered, Windows is keep bringing us surprises... Again, I am personally okay with draft PR we have for 3.10.2.

  8. hazendaz commented on Nov 18, 2026

    @hazendaz
    ContributorAuthor

    Sure @cstamas, thanks for the additional detail. JNA would probably be a better solution for Windows, but given the goal of keeping Maven lean, introducing a dependency with a roughly 2 MB footprint seems counterproductive.

    I had originally thought that all Windows 10 server variants were also out of support, but I see that's not the case.

    So while I'm covered by the current PR, which is good enough for my situation, I suspect others may still run into this. At least they'll have the documented workaround to refer to when they do.

  9. cstamas commented on Nov 18, 2026

    @cstamas
    Member

    Re documentation, yes, we had this in release notes:
    https://maven.apache.org/docs/3.10.1/release-notes.html#no-colored-output-by-default-in-windows-cmd-exe

    (as this was really the initial report upon release of 3.10.1: user using cmd.exe was surprised to lose colors. Explained in PR #13888 why)

  10. cstamas commented on Nov 18, 2026

    @cstamas
    Member

    If you are covered, I am making PR non-DRAFT and will get merged once approved.

  11. added a commit that references this issue on Nov 18, 2026
    3363ebb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions