Skip to content

Commit

Permalink
Set LC_ALL to UTF-8 encoding for builds (#793)
Browse files Browse the repository at this point in the history
  • Loading branch information
borsboom committed Aug 21, 2015
1 parent 82c6e3d commit 9787aed
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## Unreleased changes

* Added the `--docker-env` argument, to set environment variables in Docker container.
* 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)

## 0.1.3.1

Expand Down
3 changes: 3 additions & 0 deletions src/Stack/Build/Execute.hs
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,7 @@ executePlan menv bopts baseConfigOpts locals sourceMap installedMap plan = do
{ esIncludeLocals = True
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
}
forM_ (boptsExec bopts) $ \(cmd, args) -> do
$logProcessRun cmd args
Expand Down Expand Up @@ -642,6 +643,7 @@ withSingleContext ActionContext {..} ExecuteEnv {..} task@Task {..} msuffix inne
{ esIncludeLocals = taskLocation task == Local
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = True
}
getRunhaskellPath <- runOnce $ liftIO $ join $ findExecutable menv "runhaskell"
getGhcjsPath <- runOnce $ liftIO $ join $ findExecutable menv "ghcjs"
Expand Down Expand Up @@ -941,6 +943,7 @@ singleTest topts lptb ac ee task installedMap =
{ esIncludeLocals = taskLocation task == Local
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
}
if exists
then do
Expand Down
2 changes: 2 additions & 0 deletions src/Stack/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ defaultEnvSettings = EnvSettings
{ esIncludeLocals = True
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
}

-- | Environment settings which do not embellish the environment
Expand All @@ -39,6 +40,7 @@ plainEnvSettings = EnvSettings
{ esIncludeLocals = False
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = False
}

-- | Execute a process within the Stack configured environment.
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Options.hs
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ execOptsParser mcmd =
"stack-exe"
"setting the STACK_EXE environment variable to the path for the stack executable"
idm
<*> pure False

eoPackagesParser :: Parser [String]
eoPackagesParser = many (strOption (long "package" <> help "Additional packages that must be installed"))
Expand Down
4 changes: 4 additions & 0 deletions src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ setupEnv mResolveMissingGHC = do
then Map.insert "STACK_EXE" (T.pack executablePath)
else id)

$ (if esLocaleUtf8 es
then Map.insert "LC_ALL" "C.UTF-8"
else id)

-- For reasoning and duplication, see: https://github.com/fpco/stack/issues/70
$ Map.insert "HASKELL_PACKAGE_SANDBOX" (T.pack $ toFilePathNoTrailingSlash deps)
$ Map.insert "HASKELL_PACKAGE_SANDBOXES"
Expand Down
3 changes: 3 additions & 0 deletions src/Stack/Types/Config.hs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,8 @@ data EnvSettings = EnvSettings
-- ^ include the GHC_PACKAGE_PATH variable
, esStackExe :: !Bool
-- ^ set the STACK_EXE variable to the current executable name
, esLocaleUtf8 :: !Bool
-- ^ set the locale to C.UTF-8
}
deriving (Show, Eq, Ord)

Expand Down Expand Up @@ -872,6 +874,7 @@ getMinimalEnvOverride = do
{ esIncludeLocals = False
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = False
}

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

0 comments on commit 9787aed

Please sign in to comment.