@@ -97,7 +97,7 @@ import Stack.Types.Docker
97
97
import Stack.Types.SourceMap
98
98
import Stack.Types.Version
99
99
import qualified System.Directory as D
100
- import System.Environment (getExecutablePath , lookupEnv , getEnvironment )
100
+ import System.Environment (getExecutablePath , lookupEnv )
101
101
import System.IO.Error (isPermissionError )
102
102
import System.FilePath (searchPathSeparator )
103
103
import qualified System.FilePath as FP
@@ -447,21 +447,18 @@ ensureCompilerAndMsys
447
447
=> SetupOpts
448
448
-> RIO env (CompilerPaths , ExtraDirs )
449
449
ensureCompilerAndMsys sopts = do
450
+ getSetupInfo' <- memoizeRef getSetupInfo
451
+ mmsys2Tool <- ensureMsys sopts getSetupInfo'
452
+ msysPaths <- maybe (pure Nothing ) (fmap Just . extraDirs) mmsys2Tool
453
+
450
454
actual <- either throwIO pure $ wantedToActual $ soptsWantedCompiler sopts
451
455
didWarn <- warnUnsupportedCompiler $ getGhcVersion actual
452
456
453
- getSetupInfo' <- memoizeRef getSetupInfo
454
457
(cp, ghcPaths) <- ensureCompiler sopts getSetupInfo'
455
458
456
459
warnUnsupportedCompilerCabal cp didWarn
457
460
458
- mmsys2Tool <- ensureMsys sopts getSetupInfo'
459
- paths <-
460
- case mmsys2Tool of
461
- Nothing -> pure ghcPaths
462
- Just msys2Tool -> do
463
- msys2Paths <- extraDirs msys2Tool
464
- pure $ ghcPaths <> msys2Paths
461
+ let paths = maybe ghcPaths (ghcPaths <> ) msysPaths
465
462
pure (cp, paths)
466
463
467
464
-- | See <https://github.com/commercialhaskell/stack/issues/4246>
@@ -613,7 +610,9 @@ ensureCompiler sopts getSetupInfo' = do
613
610
wc <- either throwIO (pure . whichCompiler) $ wantedToActual wanted
614
611
615
612
hook <- ghcInstallHook
616
- hookIsExecutable <- handleIO (\ _ -> pure False ) $ executable <$> getPermissions hook
613
+ hookIsExecutable <- handleIO (\ _ -> pure False ) $ if osIsWindows
614
+ then doesFileExist hook -- can't really detect executable on windows, only file extension
615
+ else executable <$> getPermissions hook
617
616
618
617
Platform expectedArch _ <- view platformL
619
618
@@ -664,10 +663,10 @@ runGHCInstallHook
664
663
runGHCInstallHook sopts hook = do
665
664
logDebug " Getting hook installed compiler version"
666
665
let wanted = soptsWantedCompiler sopts
667
- curEnv <- Map. fromList . map ( T. pack *** T. pack) <$> liftIO getEnvironment
668
- let newEnv = Map. union (wantedCompilerToEnv wanted) curEnv
669
- pCtx <- mkProcessContext newEnv
670
- (exit, out) <- withProcessContext pCtx $ proc " sh" [toFilePath hook] readProcessStdout
666
+ menv0 <- view processContextL
667
+ menv <- mkProcessContext ( Map. union (wantedCompilerToEnv wanted) $
668
+ removeHaskellEnvVars (view envVarsL menv0))
669
+ (exit, out) <- withProcessContext menv $ proc " sh" [toFilePath hook] readProcessStdout
671
670
case exit of
672
671
ExitSuccess -> do
673
672
let ghcPath = stripNewline . TL. unpack . TL. decodeUtf8With T. lenientDecode $ out
0 commit comments