@@ -30,7 +30,7 @@ import Control.Exception
30
30
import System.FilePath
31
31
import System.Directory (getCurrentDirectory , canonicalizePath , findExecutable )
32
32
import System.Exit
33
- import System.Process (readCreateProcessWithExitCode , shell )
33
+ import System.Process (readCreateProcessWithExitCode , shell , CreateProcess ( .. ) )
34
34
35
35
import Haskell.Ide.Engine.Logger
36
36
@@ -102,7 +102,7 @@ execProjectGhc crdl args = do
102
102
ghcOutput <- if isStackCradle crdl && isStackInstalled
103
103
then do
104
104
logm $ " Executing Stack GHC with args: " <> unwords args
105
- catch (Just <$> tryCommand stackCmd) $ \ (_ :: IOException ) -> do
105
+ catch (Just <$> tryCommand crdl stackCmd) $ \ (_ :: IOException ) -> do
106
106
errorm $ " Command `" ++ stackCmd ++ " ` failed."
107
107
execWithGhc
108
108
-- The command `cabal v2-exec -v0 ghc` only works if the project has been
@@ -112,7 +112,7 @@ execProjectGhc crdl args = do
112
112
--
113
113
-- else if isCabalCradle crdl && isCabalInstalled then do
114
114
-- let cmd = "cabal v2-exec -v0 ghc -- " ++ unwords args
115
- -- catch (Just <$> tryCommand cmd) $ \(_ ::IOException) -> do
115
+ -- catch (Just <$> tryCommand crdl cmd) $ \(_ ::IOException) -> do
116
116
-- errorm $ "Command `" ++ cmd ++ "` failed."
117
117
-- return Nothing
118
118
else do
@@ -125,13 +125,14 @@ execProjectGhc crdl args = do
125
125
plainCmd = " ghc " ++ unwords args
126
126
127
127
execWithGhc =
128
- catch (Just <$> tryCommand plainCmd) $ \ (_ :: IOException ) -> do
128
+ catch (Just <$> tryCommand crdl plainCmd) $ \ (_ :: IOException ) -> do
129
129
errorm $ " Command `" ++ plainCmd ++ " ` failed."
130
130
return Nothing
131
131
132
- tryCommand :: String -> IO String
133
- tryCommand cmd = do
134
- (code, sout, serr) <- readCreateProcessWithExitCode (shell cmd) " "
132
+ tryCommand :: Cradle -> String -> IO String
133
+ tryCommand crdl cmd = do
134
+ let p = (shell cmd) { cwd = Just (cradleRootDir crdl) }
135
+ (code, sout, serr) <- readCreateProcessWithExitCode p " "
135
136
case code of
136
137
ExitFailure e -> do
137
138
let errmsg = concat
0 commit comments