From 6e58af34411ae9ab3fe0680c09ba714a5d187da1 Mon Sep 17 00:00:00 2001 From: Michael Sloan Date: Tue, 19 Sep 2017 19:47:06 -0700 Subject: [PATCH] Drop GHCRTS envvar unless user is asking for execution #3444 --- ChangeLog.md | 4 ++++ src/Stack/Build/Execute.hs | 3 +++ src/Stack/Exec.hs | 10 +++++++++- src/Stack/Hoogle.hs | 1 + src/Stack/Setup.hs | 13 ++++++++++++- src/Stack/Types/Config.hs | 3 +++ 6 files changed, 32 insertions(+), 2 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 3847cb4424..3af7d8a30f 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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: diff --git a/src/Stack/Build/Execute.hs b/src/Stack/Build/Execute.hs index 3cd3c9eb7c..8dbd5e6876 100644 --- a/src/Stack/Build/Execute.hs +++ b/src/Stack/Build/Execute.hs @@ -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 $ @@ -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 @@ -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 diff --git a/src/Stack/Exec.hs b/src/Stack/Exec.hs index cbf3e5e316..f937b003c0 100644 --- a/src/Stack/Exec.hs +++ b/src/Stack/Exec.hs @@ -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. diff --git a/src/Stack/Hoogle.hs b/src/Stack/Hoogle.hs index 6d9dba17f2..db7215a2f5 100644 --- a/src/Stack/Hoogle.hs +++ b/src/Stack/Hoogle.hs @@ -203,4 +203,5 @@ hoogleCmd (args,setup,rebuild) go = withBuildConfig go $ do , esIncludeGhcPackagePath = True , esStackExe = True , esLocaleUtf8 = False + , esKeepGhcRts = False } diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index bf7785d1b9..c554fa7e29 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -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" @@ -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" diff --git a/src/Stack/Types/Config.hs b/src/Stack/Types/Config.hs index 1f233b984f..db9382bc13 100644 --- a/src/Stack/Types/Config.hs +++ b/src/Stack/Types/Config.hs @@ -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) @@ -1412,6 +1414,7 @@ minimalEnvSettings = , esIncludeGhcPackagePath = False , esStackExe = False , esLocaleUtf8 = False + , esKeepGhcRts = False } -- | Get the path for the given compiler ignoring any local binaries.