@@ -32,7 +32,7 @@ import System.Directory (getCurrentDirectory, canonicalizePath, findEx
32
32
import System.Exit
33
33
import System.FilePath
34
34
import System.Log.Logger
35
- import System.Process (readCreateProcessWithExitCode , shell )
35
+ import System.Process (readCreateProcessWithExitCode , shell , CreateProcess ( .. ) )
36
36
37
37
38
38
-- ---------------------------------------------------------------------
@@ -105,7 +105,7 @@ execProjectGhc crdl args = do
105
105
ghcOutput <- if isStackCradle crdl && isStackInstalled
106
106
then do
107
107
logm $ " Executing Stack GHC with args: " <> unwords args
108
- catch (Just <$> tryCommand stackCmd) $ \ (_ :: IOException ) -> do
108
+ catch (Just <$> tryCommand crdl stackCmd) $ \ (_ :: IOException ) -> do
109
109
errorm $ " Command `" ++ stackCmd ++ " ` failed."
110
110
execWithGhc
111
111
-- The command `cabal v2-exec -v0 ghc` only works if the project has been
@@ -115,7 +115,7 @@ execProjectGhc crdl args = do
115
115
--
116
116
-- else if isCabalCradle crdl && isCabalInstalled then do
117
117
-- let cmd = "cabal v2-exec -v0 ghc -- " ++ unwords args
118
- -- catch (Just <$> tryCommand cmd) $ \(_ ::IOException) -> do
118
+ -- catch (Just <$> tryCommand crdl cmd) $ \(_ ::IOException) -> do
119
119
-- errorm $ "Command `" ++ cmd ++ "` failed."
120
120
-- return Nothing
121
121
else do
@@ -128,13 +128,14 @@ execProjectGhc crdl args = do
128
128
plainCmd = " ghc " ++ unwords args
129
129
130
130
execWithGhc =
131
- catch (Just <$> tryCommand plainCmd) $ \ (_ :: IOException ) -> do
131
+ catch (Just <$> tryCommand crdl plainCmd) $ \ (_ :: IOException ) -> do
132
132
errorm $ " Command `" ++ plainCmd ++ " ` failed."
133
133
return Nothing
134
134
135
- tryCommand :: String -> IO String
136
- tryCommand cmd = do
137
- (code, sout, serr) <- readCreateProcessWithExitCode (shell cmd) " "
135
+ tryCommand :: Cradle CabalHelper -> String -> IO String
136
+ tryCommand crdl cmd = do
137
+ let p = (shell cmd) { cwd = Just (cradleRootDir crdl) }
138
+ (code, sout, serr) <- readCreateProcessWithExitCode p " "
138
139
case code of
139
140
ExitFailure e -> do
140
141
let errmsg = concat
0 commit comments