Skip to content

Commit cf05aa9

Browse files
committed
Check if the tool is installed in --project-ghc-version in the wrapper
1 parent a5c5608 commit cf05aa9

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

exe/Wrapper.hs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,30 @@ main = do
7373
hPutStrLn stderr $ "Launching haskell-language-server exe at:" ++ e
7474
callProcess e args
7575

76-
-- | Version of 'getRuntimeGhcVersion' that dies if we can't get it
77-
getRuntimeGhcVersion' :: Cradle a -> IO String
76+
-- | Version of 'getRuntimeGhcVersion' that dies if we can't get it, and also
77+
-- checks to see if the tool is missing if it is one of
78+
getRuntimeGhcVersion' :: Show a => Cradle a -> IO String
7879
getRuntimeGhcVersion' cradle = do
80+
81+
-- See if the tool is installed
82+
case actionName (cradleOptsProg cradle) of
83+
Stack -> checkToolExists "stack"
84+
Cabal -> checkToolExists "cabal"
85+
Default -> checkToolExists "ghc"
86+
Direct -> checkToolExists "ghc"
87+
_ -> pure ()
88+
7989
ghcVersionRes <- getRuntimeGhcVersion cradle
8090
case ghcVersionRes of
8191
CradleSuccess ver -> do
8292
return ver
8393
CradleFail error -> die $ "Failed to get project GHC version:" ++ show error
8494
CradleNone -> die "Failed get project GHC version, since we have a none cradle"
95+
where
96+
checkToolExists exe = do
97+
exists <- findExecutable exe
98+
case exists of
99+
Just _ -> pure ()
100+
Nothing ->
101+
die $ "Cradle requires " ++ exe ++ " but couldn't find it" ++ "\n"
102+
++ show cradle

ghcide

0 commit comments

Comments
 (0)