问题
I'm running GHC using Stack on Windows 10, and using Git Bash (MINGW64) for much of my daily workflow. That includes using GHC and GHCi, which generally works fine.
However, when I run stack test
from MINGW64, the output is garbled by ANSI color codes:
$ stack test
UC-0.1.0.0: test (suite: UC-test)
[?25lSorting Group 1:
[2K[1F prop1: [[92mOK, passed 100 tests[0m]
[2K[1F prop2: [[92mOK, passed 100 tests[0m]
Properties Total
Passed [92m2[0m [92m2[0m
Failed 0 0
Total [92m2[0m [92m2[0m
[?25h
Strangely, if I run stack test
from the normal Windows console (cmd
), it displays correctly:
I'd like to stick with my (Git) Bash console instead of having to use two separate console windows, so:
- Is it possible to get the colours to render correctly for
stack test
in MINGW64? - Alternatively, can I turn off ANSI colouring for
stack test
, so that, at least, it's easier to read the output?
I've also tried to run variations of stack --color never test
, but it doesn't seem to make any difference.
回答1:
Arguments can be passed to the test executable like this:
stack test --test-arguments "--plain"
--plain
is the option to remove colors in test-framework, while --color never
is from tasty.
回答2:
I have been having this same issue on Windows 10, Git 2.17.0, with MINGW64 as the Git Bash shell. Colors are fine until I run "php artisan tinker", after which colors cease and suddenly all output is garbled with the ANSI color codes.
My solution turned out to be (it surprised me that it worked): run Bash inside the Git Bash shell.
Before:
$ php artisan tinker
?[34mPsy Shell v0.7.2 (PHP 7.1.11 ΓÇö cli) by Justin Hileman?[39m
>>> exit
?[37;41mExit: Goodbye.?[39;49m
$
After:
$ bash
$ php artisan tinker
Psy Shell v0.7.2 (PHP 7.1.11 — cli) by Justin Hileman
>>> exit
Exit: Goodbye.
$
It's really a work-around, but it works. Maybe this is a clue to the actual underlying issue. Terminal type did not seem to matter (xterm, xterm-256, etc.) were all tried with little difference.
来源:https://stackoverflow.com/questions/45608617/stack-test-output-garbled-on-mingw64