Skip to content

Commit

Permalink
Drop GHCRTS envvar unless user is asking for execution #3444
Browse files Browse the repository at this point in the history
  • Loading branch information
mgsloan committed Sep 20, 2017
1 parent 7b07c46 commit 6e58af3
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ Behavior changes:
* Stack will ask before saving hackage credentials to file. This new
prompt can be avoided by using the `save-hackage-creds` setting. Please
see [#2159](https://github.com/commercialhaskell/stack/issues/2159).
* The `GHCRTS` environment variable will no longer be passed to
every program stack runs. Instead, it will only be passed through
commands like `exec`, `runghc`, `script`, `ghci`, etc.
See [#3444](https://github.com/commercialhaskell/stack/issues/3444).

Other enhancements:

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 @@ -496,6 +496,7 @@ executePlan menv boptsCli baseConfigOpts locals globalPackages snapshotPackages
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
, esKeepGhcRts = False
}
forM_ (boptsCLIExec boptsCli) $ \(cmd, args) ->
withProcessTimeLog cmd args $
Expand Down Expand Up @@ -936,6 +937,7 @@ withSingleContext runInBase ActionContext {..} ExecuteEnv {..} task@Task {..} md
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = True
, esKeepGhcRts = False
}
menv <- liftIO $ configEnvOverride config envSettings
distRelativeDir' <- distRelativeDir
Expand Down Expand Up @@ -1619,6 +1621,7 @@ singleTest runInBase topts testsToRun ac ee task installedMap = do
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
, esKeepGhcRts = False
}
if exists
then do
Expand Down
10 changes: 9 additions & 1 deletion src/Stack/Exec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,30 @@ import qualified System.Process.PID1 as PID1
import System.Process.Read (EnvOverride, envHelper, preProcess)
#endif

-- | Default @EnvSettings@ which includes locals and GHC_PACKAGE_PATH
-- | Default @EnvSettings@ which includes locals and GHC_PACKAGE_PATH.
--
-- Note that this also passes through the GHCRTS environment variable.
-- See https://github.com/commercialhaskell/stack/issues/3444
defaultEnvSettings :: EnvSettings
defaultEnvSettings = EnvSettings
{ esIncludeLocals = True
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
, esKeepGhcRts = True
}

-- | Environment settings which do not embellish the environment
--
-- Note that this also passes through the GHCRTS environment variable.
-- See https://github.com/commercialhaskell/stack/issues/3444
plainEnvSettings :: EnvSettings
plainEnvSettings = EnvSettings
{ esIncludeLocals = False
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = False
, esKeepGhcRts = True
}

-- | Execute a process within the Stack configured environment.
Expand Down
1 change: 1 addition & 0 deletions src/Stack/Hoogle.hs
Original file line number Diff line number Diff line change
Expand Up @@ -203,4 +203,5 @@ hoogleCmd (args,setup,rebuild) go = withBuildConfig go $ do
, esIncludeGhcPackagePath = True
, esStackExe = True
, esLocaleUtf8 = False
, esKeepGhcRts = False
}
13 changes: 12 additions & 1 deletion src/Stack/Setup.hs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,11 @@ setupEnv mResolveMissingGHC = do
-> Map.insert "MSYSTEM" "MINGW64"
_ -> id

-- See https://github.com/commercialhaskell/stack/issues/3444
$ (if esKeepGhcRts es
then id
else Map.delete "GHCRTS")

-- For reasoning and duplication, see: https://github.com/fpco/stack/issues/70
$ Map.insert "HASKELL_PACKAGE_SANDBOX" (T.pack $ toFilePathNoTrailingSep deps)
$ Map.insert "HASKELL_PACKAGE_SANDBOXES"
Expand Down Expand Up @@ -1200,7 +1205,13 @@ bootGhcjs ghcjsVersion stackYaml destDir bootOpts = do
"See this issue: https://github.com/ghcjs/ghcjs/issues/470"
return True
| otherwise -> return False
let envSettings = defaultEnvSettings { esIncludeGhcPackagePath = False }
let envSettings = EnvSettings
{ esIncludeLocals = True
, esIncludeGhcPackagePath = False
, esStackExe = True
, esLocaleUtf8 = True
, esKeepGhcRts = False
}
menv' <- liftIO $ configEnvOverride (view configL envConfig) envSettings
shouldInstallAlex <- not <$> doesExecutableExist menv "alex"
shouldInstallHappy <- not <$> doesExecutableExist menv "happy"
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 @@ -401,6 +401,8 @@ data EnvSettings = EnvSettings
-- ^ set the STACK_EXE variable to the current executable name
, esLocaleUtf8 :: !Bool
-- ^ set the locale to C.UTF-8
, esKeepGhcRts :: !Bool
-- ^ if True, keep GHCRTS variable in environment
}
deriving (Show, Eq, Ord)

Expand Down Expand Up @@ -1412,6 +1414,7 @@ minimalEnvSettings =
, esIncludeGhcPackagePath = False
, esStackExe = False
, esLocaleUtf8 = False
, esKeepGhcRts = False
}

-- | Get the path for the given compiler ignoring any local binaries.
Expand Down

0 comments on commit 6e58af3

Please sign in to comment.