Wednesday, February 14, 2024

Fixing an error "commitAndReleaseBuffer: invalid argument (invalid character)" in stack-building Haskell

 

On Windows, I often meet this annoying error:

 - stack build

   ...

   commitAndReleaseBuffer: invalid argument (invalid character)

   ...


This error seems to happen due to a locale setting on Windows. To see what is set for the locale, you can try the following PowerShell commands: 

 - Get-WinSystemLocale

 - Set-WinSystemLocale en-US

My locale was set for Korean. I changed it to en-US, and the error was magically gone away!


The locale setting command should run on PowerShell under the system manager mode.


On Ubuntu, I have rarely seen such an error, "commitAndReleaseBuffer: invalid argument (invalid character)".


More important thing: such an error is not just solely from locale settings, but it is actually caused by some real error in the haskell program to build. 


My guess is that there is something wrong in a Haskell program. Haskell stack or ghc detects it. It tries to write something about the detected error somewhere (perhaps, using SQL?), and the relevant Haskell library meets a locale setting problem, producing this famous error message:

  - commitAndReleaseBuffer: invalid argument (invalid character)