4

Hi I installed cygwin version 3.1.5 on a Win10 mashine. When I use maven for example then the output is not really correct. The square brackets are shown in a wrong way. Here an example

[?[1;34mINFO?[m] ?[1m------------------------------------------------------------------------?[m
[?[1;34mINFO?[m] ?[1;32mBUILD SUCCESS?[m
[?[1;34mINFO?[m] ?[1m------------------------------------------------------------------------?[m
[?[1;34mINFO?[m] Total time:  2:42 min
[?[1;34mINFO?[m] Finished at: 2020-06-10T15:26:07+02:00
[?[1;34mINFO?[m] ?[1m------------------------------------------------------------------------?[m

I can't figure out if this could be a locale problem because I don't understand how to change it and if it is really there the problem. Have someone of you some tips?

UPDATE -11.06.2020:

I found that probably the maven version could be the problem. For me this sounds strange. I run maven version 3.6.3: https://intellij-support.jetbrains.com/hc/en-us/community/posts/115000687110-Using-Mingw-as-terminal-doesn-t-display-ANSI-colors-in-Maven-output

Thanks a lot

code4fun
  • 1,012
  • 3
  • 24
  • 41
  • 1
    Those odd looking braces are intended to change the color of the word "INFO". They are control codes to change the color, E.g. "ESC [ 1;34m" and "ESC [ m" to reset it.Presumably errors and warnings would each have different colors. Are you running cygwin in the mintty terminal? Try that. Are you running the output through more or less? You might try "less -r". IIRC, maven is a Java program, so it may not work well in cygwin. Try adding a Maven tag to your question, and remove encoding to improve the target audience. – Doug Henderson Jun 10 '20 at 16:37
  • Thanks for your suggestions. The thing is that I run cygwin from intellij as terminal. I tried out mintty but this leads to a window out from intellij. And it's not really an option for me. But I found an other link that I added to the description above. – code4fun Jun 11 '20 at 05:33
  • Does it work in OS terminal? – Andrey Jun 11 '20 at 08:00
  • `I found that probably the maven version could be the problem` - you can change the Maven version in Settings (Preferences on macOS) | Build, Execution, Deployment | Build Tools | Maven | **Maven home directory**. Does it help to download Maven 3.5.0 version and set it for the IDE? – Andrey Jun 11 '20 at 08:01
  • This has been fixed in Maven 3.8.2 – AntikM Sep 15 '21 at 23:08

5 Answers5

5

check your TERM environment property and ensure it is set to "cygwin". For example,

TERM="cygwin"; export TERM

rubens
  • 460
  • 7
  • 8
3

as suggested here https://stackoverflow.com/a/62971169 on cygwin if you pipe the output to a tee it works!!!

you can alias the mvn command with a function with something like:

function mvn() {  $M2_HOME/bin/mvn $@ | tee }

inside your .bash_profile or .bash_alias

thebol
  • 175
  • 1
  • 7
  • Cool idea. But you should really put double-quotes around the `$@` for safety. See https://stackoverflow.com/questions/37141039/is-there-any-difference-between-and – Adam Dec 08 '20 at 07:19
  • Note that my problem was different - colours and brackets displayed OK, but it was adding (apparently) random spaces into the output - in the middle of package paths and things. Same solution fixes this. – Adam Dec 08 '20 at 08:18
0

At the end the solution for me was:

I put the cygwin path in the PATH variable.

Now I don't run anymore the cygwin itself, but I have directly the functionlities when i start cmd.exe

code4fun
  • 1,012
  • 3
  • 24
  • 41
0

I ran into the same problem when using Maven 3.6.3 with Cygwin.

This is a problem of a Maven 3rd library: Jansi.

Maven 3.6.3 uses Jansi 1.1.17 but support for Cygwin was added with Jansi 1.1.18. See this Jansi bug and this Jansi commit.

I came to this conclusion after reading the following web page and looking into Maven and Jansi code.

Maybe we can convince the Maven guys somehow to switch to the newer Jansi lib :)

Thorsten
  • 315
  • 2
  • 7
  • Tried to download jansi 1.18 and replace 1.17.1. Still same issue. – eirirlar Sep 24 '20 at 20:30
  • 1
    Here is the bug that describes the issue and the fix: https://github.com/fusesource/jansi/issues/94 I just tested with maven 3.8.2 and it works! – Thorsten Aug 31 '21 at 13:41
0

Maybe not a definitive answer, but if you pipe everything to egrep, the colors will come back.

mvn clean install | egrep ".*"
user2342460
  • 114
  • 4