4
votes

I am a Windows user that recently moved to the latest stack (1.6.3), and the latest GHC (8.2.2). It seems that in the latest GHC there's color output possible with error messages. Color happens via ANSI escape sequences that windows doesn't understand, so it just shows a bunch of garbage text between the real text.

[1 of 2] Compiling IOSystem.Haskeline ( app\IOSystem\Haskeline.hs, .stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp\IOSystem\Haskeline.o )

←[;1mapp\IOSystem\Haskeline.hs:28:13: ←[;1m←[31merror:←[0m←[0m←[;1m←[0m←[0m←[;1m
    * Couldn't match type `[Char]' with `Text'
      Expected type: InputT m (LineResult Text)
        Actual type: InputT m (Either LineFailure String)
    * In a stmt of a 'do' block: pure $ Right line
      In the expression:
        do modifyHistory $ addHistoryUnlessConsecutiveDupe line
           pure $ Right line
      In a case alternative:
          Just line
            -> do modifyHistory $ addHistoryUnlessConsecutiveDupe line
                  pure $ Right line←[0m←[0m
←[;1m←[34m   |←[0m←[0m
←[;1m←[34m28 |←[0m←[0m             ←[;1m←[31mpure $ Right line←[0m←[0m
←[;1m←[34m   |←[0m←[0m←[;1m←[31m             ^^^^^^^^^^^^^^^^^←[0m←[0m
←[0m←[0m←[0m

I tried putting ghc-options: -fdiagnostics-color=never in both the library and executable portion of my project.cabal file but it seemed to have no effect. I re-ran with verbose output and it seems that stack is putting its own "-fdiagnostics-color=always" command after the ghc-options that I specify.

I just need stack to somehow not do that.

stack -v --cabal-verbose build

(much text omitted)

2018-01-14 18:54:24.009085: [info] "C:\Users\Daniel\AppData\Local\Programs\stack\x86_64-windows\ghc-8.2.2\bin\ghc.EXE" "--make" "-no-link" "-fbuilding-cabal-package" "-O" "-static" "-outputdir" ".stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-odir" ".stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-hidir" ".stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-stubdir" ".stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-i" "-i.stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-iapp" "-i.stack-work\dist\5c8418a7\build\galbreak\autogen" "-i.stack-work\dist\5c8418a7\build\global-autogen" "-I.stack-work\dist\5c8418a7\build\galbreak\autogen" "-I.stack-work\dist\5c8418a7\build\global-autogen" "-I.stack-work\dist\5c8418a7\build\galbreak\galbreak-tmp" "-IC:\Users\Daniel\AppData\Local\Programs\stack\x86_64-windows\msys2-20150512\mingw64\include" "-optP-include" "-optP.stack-work\dist\5c8418a7\build\galbreak\autogen\cabal_macros.h" "-hide-all-packages" "-Wmissing-home-modules" "-no-user-package-db" "-package-db" "C:\sr\snapshots\13cecb13\pkgdb" "-package-db" "D:\dev\galaxy-break.stack-work\install\ccbce92a\pkgdb" "-package-db" ".stack-work\dist\5c8418a7\package.conf.inplace" "-package-id" "base-4.10.1.0" "-package-id" "text-1.2.2.2-9VTsh6V7U7hpagw2HDvpZ" "-package-id" "haskeline-0.7.4.2-DGuJCOcZAmc2Ddce2AkQr0" "-XHaskell2010" "IOSystem.Haskeline" "app\Main.hs" "-W" "-threaded" "-rtsopts" "-with-rtsopts=-N" "-O2" "-fdiagnostics-color=never" "-ddump-hi" "-ddump-to-file" "-fdiagnostics-color=always"

1

1 Answers

4
votes

You can use --color never.

It seems that you are using an unusual terminal configuration. One option for fixing this might be to submit a PR to ansi-terminal to make it so that https://hackage.haskell.org/package/ansi-terminal-0.8/docs/System-Console-ANSI.html#v:hSupportsANSI yields False for your terminal

It is not currently possible to specify this in your config.yaml, but perhaps it should be - I have opened https://github.com/commercialhaskell/stack/issues/3778 to track adding it. Not a high priority