3

I am new to Haskell recently, but I am currently facing a very annoying problem:

I followed instructions from here, and installed Haskell platform on Windows10 with default settings. But when I tried to run

cabal install [package name]

to install a haskell package, I always got the error:

C:\Users\[My Username]\AppData\Local\Temp\ghc20156_0\ghc_2.rsp: commitBuffer: invalid argument (invalid character)

Thus, I am not able to install any Haskell packages, which annoys me a lot.

I wanted to figure out a solution to the problem, but I failed. So how can I fix this error? I hope some of you could tell me.

Arsenal591
  • 1,396
  • 2
  • 9
  • 12
  • 2
    Unless you did something strange, this is a bug with the haskell platform. You should submit a bug report to them. Meanwhile, you could try using `stack` instead of cabal-install https://haskell-lang.org/get-started Stack seems to be part of the haskell platform nowadays. – Cubic Feb 26 '18 at 12:02
  • @Cubic This might not be specific to the Platform. [Stack issue #1870](https://github.com/commercialhaskell/stack/issues/1870) seems relevant. – duplode Feb 26 '18 at 14:53
  • 1
    @duplode Ugh, windows and unicode :( – Cubic Feb 26 '18 at 14:55
  • @Cubic For the sake of completeness: I recently got the same error when I had to build my Hakyll sites (installing packages in general worked fine) on a pt-BR Win 10 machine. I didn't investigate further (not yet, at least) because the `hSetEncoding` workaround in the [Hakyll FAQ](https://jaspervdj.be/hakyll/tutorials/faq.html#hgetcontents-invalid-argument-or-commitbuffer-invalid-argument) was good enough for my immediate purposes. – duplode Feb 26 '18 at 15:32
  • 3
    @Arsenal591 Two things you might try, taken from the discussions linked to above: (1) [In the Control Panel, change "Current language for non-Unicode programs" to "English (United States)](https://superuser.com/a/1199477/320921); (2) [Run `chcp.com 65001` in the console](https://stackoverflow.com/a/27622364/2751851). – duplode Feb 27 '18 at 12:57
  • Turns out that works! Thanks a lot. – Arsenal591 Mar 06 '18 at 12:33
  • @duplode can you post your comment as an answer. – sclv Mar 15 '18 at 18:47
  • Also, @Cubic can you not recommend people switch from the platform to stack for every issue without first investigating, much more commonly it is something else, such as this... – sclv Mar 15 '18 at 18:48
  • @sclv Posted. (I didn't do that at first because I hadn't tried all of the workarounds yet -- thanks for drawing my attention back to this.) – duplode Mar 16 '18 at 03:36
  • @Arsenal591 Good to know; you're welcome :) I have only seen your reply now, as you hadn't @-notified me. – duplode Mar 16 '18 at 03:44

1 Answers1

3

This very likely is an encoding issue related to the configuration of your OS. When I got the same message on trying to run a Hakyll program on Windows, I found that running chcp 65001 in the Windows console, as suggested by the Hakyll FAQ, worked as a workaround.

(Adding setLocaleEncoding utf8 to main, as described there, also helped in my case; that doesn't apply to your situation, though. A reply to the similar-looking Stack issue #1870 suggests changing "Current language for non-Unicode programs" to "English (United States)" in the Windows Control Panel; however, doing so made no difference in my pt-BR Win 10 Home system.)

duplode
  • 33,731
  • 7
  • 79
  • 150