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)


2 comments:

Francesco said...

Could be this https://gitlab.haskell.org/ghc/ghc/-/issues/7593

Note that default native Win IO is not yet in released GHC, so we need to wait a bit more.

lazyswamp said...

The issue must be relevant to mine. Thanks a lot!