Skip to content

Commit 9787aed

Browse files
committed
Set LC_ALL to UTF-8 encoding for builds (commercialhaskell#793)
1 parent 82c6e3d commit 9787aed

6 files changed

Lines changed: 14 additions & 0 deletions

File tree

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
## Unreleased changes
22

33
* Added the `--docker-env` argument, to set environment variables in Docker container.
4+
* Set `LC_ALL` to UTF-8 encoding for builds to avoid "commitBuffer: invalid argument" errors from GHC [#793](https://github.com/commercialhaskell/stack/issues/793)
45

56
## 0.1.3.1
67

src/Stack/Build/Execute.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -388,6 +388,7 @@ executePlan menv bopts baseConfigOpts locals sourceMap installedMap plan = do
388388
{ esIncludeLocals = True
389389
, esIncludeGhcPackagePath = True
390390
, esStackExe = True
391+
, esLocaleUtf8 = False
391392
}
392393
forM_ (boptsExec bopts) $ \(cmd, args) -> do
393394
$logProcessRun cmd args
@@ -642,6 +643,7 @@ withSingleContext ActionContext {..} ExecuteEnv {..} task@Task {..} msuffix inne
642643
{ esIncludeLocals = taskLocation task == Local
643644
, esIncludeGhcPackagePath = False
644645
, esStackExe = False
646+
, esLocaleUtf8 = True
645647
}
646648
getRunhaskellPath <- runOnce $ liftIO $ join $ findExecutable menv "runhaskell"
647649
getGhcjsPath <- runOnce $ liftIO $ join $ findExecutable menv "ghcjs"
@@ -941,6 +943,7 @@ singleTest topts lptb ac ee task installedMap =
941943
{ esIncludeLocals = taskLocation task == Local
942944
, esIncludeGhcPackagePath = True
943945
, esStackExe = True
946+
, esLocaleUtf8 = False
944947
}
945948
if exists
946949
then do

src/Stack/Exec.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ defaultEnvSettings = EnvSettings
3131
{ esIncludeLocals = True
3232
, esIncludeGhcPackagePath = True
3333
, esStackExe = True
34+
, esLocaleUtf8 = False
3435
}
3536

3637
-- | Environment settings which do not embellish the environment
@@ -39,6 +40,7 @@ plainEnvSettings = EnvSettings
3940
{ esIncludeLocals = False
4041
, esIncludeGhcPackagePath = False
4142
, esStackExe = False
43+
, esLocaleUtf8 = False
4244
}
4345

4446
-- | Execute a process within the Stack configured environment.

src/Stack/Options.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ execOptsParser mcmd =
465465
"stack-exe"
466466
"setting the STACK_EXE environment variable to the path for the stack executable"
467467
idm
468+
<*> pure False
468469

469470
eoPackagesParser :: Parser [String]
470471
eoPackagesParser = many (strOption (long "package" <> help "Additional packages that must be installed"))

src/Stack/Setup.hs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,10 @@ setupEnv mResolveMissingGHC = do
216216
then Map.insert "STACK_EXE" (T.pack executablePath)
217217
else id)
218218

219+
$ (if esLocaleUtf8 es
220+
then Map.insert "LC_ALL" "C.UTF-8"
221+
else id)
222+
219223
-- For reasoning and duplication, see: https://github.com/fpco/stack/issues/70
220224
$ Map.insert "HASKELL_PACKAGE_SANDBOX" (T.pack $ toFilePathNoTrailingSlash deps)
221225
$ Map.insert "HASKELL_PACKAGE_SANDBOXES"

src/Stack/Types/Config.hs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,8 @@ data EnvSettings = EnvSettings
190190
-- ^ include the GHC_PACKAGE_PATH variable
191191
, esStackExe :: !Bool
192192
-- ^ set the STACK_EXE variable to the current executable name
193+
, esLocaleUtf8 :: !Bool
194+
-- ^ set the locale to C.UTF-8
193195
}
194196
deriving (Show, Eq, Ord)
195197

@@ -872,6 +874,7 @@ getMinimalEnvOverride = do
872874
{ esIncludeLocals = False
873875
, esIncludeGhcPackagePath = False
874876
, esStackExe = False
877+
, esLocaleUtf8 = False
875878
}
876879

877880
getWhichCompiler :: (MonadReader env m, HasEnvConfig env) => m WhichCompiler

0 commit comments

Comments
 (0)