From fe620835bed78b7d0920d150accab708734872e4 Mon Sep 17 00:00:00 2001 From: Julian Ospald Date: Mon, 6 Jun 2022 20:18:10 +0200 Subject: [PATCH] Fix 'ghcup run' on windows, fixes #375 --- lib/GHCup/Prelude/Process/Windows.hs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/GHCup/Prelude/Process/Windows.hs b/lib/GHCup/Prelude/Process/Windows.hs index 17c75ac..fb9b255 100644 --- a/lib/GHCup/Prelude/Process/Windows.hs +++ b/lib/GHCup/Prelude/Process/Windows.hs @@ -206,6 +206,13 @@ exec :: MonadIO m -> Maybe [(String, String)] -- ^ optional environment -> m (Either ProcessError ()) exec exe args chdir env = do + -- https://gitlab.haskell.org/haskell/ghcup-hs/-/issues/375 + forM_ (Map.fromList <$> env) $ \cEnv -> do + let paths = ["PATH", "Path"] + curPaths = (\x -> maybe [] splitSearchPath (Map.lookup x cEnv)) =<< paths + newPath = intercalate [searchPathSeparator] curPaths + setEnv "PATH" "" + setEnv "Path" newPath cp <- createProcessWithMingwPath ((proc exe args) { cwd = chdir, env = env }) exit_code <- liftIO $ withCreateProcess cp $ \_ _ _ p -> waitForProcess p pure $ toProcessError exe args exit_code