diff --git a/ChangeLog.md b/ChangeLog.md index 6e6ef4e0db..2d205a387c 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -22,6 +22,8 @@ Bug fixes: [#5545](https://github.com/commercialhaskell/stack/issues/5545) * Bump `pantry` version for better OS support. See [pantry#33](https://github.com/commercialhaskell/pantry/issues/33) +* When building the sanity check for a new GHC install, make sure to clear + `GHC_PACKAGE_PATH`. ## v2.7.1 diff --git a/src/Stack/Setup.hs b/src/Stack/Setup.hs index d56262a4bf..a22b0ef346 100644 --- a/src/Stack/Setup.hs +++ b/src/Stack/Setup.hs @@ -673,9 +673,16 @@ ensureSandboxedCompiler sopts getSetupInfo' = do case res of Left _ -> loop xs Right y -> parseAbsFile y - compiler <- withProcessContext menv $ loop names + compiler <- withProcessContext menv $ do + compiler <- loop names + + -- Run this here to ensure that the sanity check uses the modified + -- environment, otherwise we may infect GHC_PACKAGE_PATH and break sanity + -- checks. + when (soptsSanityCheck sopts) $ sanityCheck compiler + + pure compiler - when (soptsSanityCheck sopts) $ sanityCheck compiler cp <- pathsFromCompiler wc compilerBuild True compiler pure (cp, paths)