File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -73,12 +73,30 @@ main = do
73
73
hPutStrLn stderr $ " Launching haskell-language-server exe at:" ++ e
74
74
callProcess e args
75
75
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
78
79
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
+
79
89
ghcVersionRes <- getRuntimeGhcVersion cradle
80
90
case ghcVersionRes of
81
91
CradleSuccess ver -> do
82
92
return ver
83
93
CradleFail error -> die $ " Failed to get project GHC version:" ++ show error
84
94
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
You can’t perform that action at this time.
0 commit comments