Skip to content
This repository was archived by the owner on Oct 7, 2020. It is now read-only.

Commit 814aa51

Browse files
committed
hie-wrapper deals with missing System GHC
Closes haskell/vscode-haskell#110 Closes #803 Sample log lines 2018-12-28 14:36:23.081677593 [ThreadId 4] - run entered for hie-wrapper(hie-wrapper) Version 0.4.0.1, Git revision 4f0c017 (dirty) (2286 commits) x86_64 ghc-8.6.3 2018-12-28 14:36:23.08184515 [ThreadId 4] - Current directory:/tmp/ff 2018-12-28 14:36:23.0846877 [ThreadId 4] - Cradle directory:/tmp/ff 2018-12-28 14:36:23.084807006 [ThreadId 4] - Using plain GHC version 2018-12-28 14:36:23.084980989 [ThreadId 4] - Project GHC version:No System GHC found 2018-12-28 14:36:23.085006736 [ThreadId 4] - hie exe candidates :["hie-No System GHC found","hie","hie"] 2018-12-28 14:36:23.085201395 [ThreadId 4] - found hie exe at:/home/alanz/.local/bin/hie 2018-12-28 14:36:23.085228858 [ThreadId 4] - args:["--lsp","-d","-l","/tmp/hie.log"] 2018-12-28 14:36:23.085252547 [ThreadId 4] - launching .... 2018-12-28 14:36:23.087026804 [ThreadId 4] - Using plain GHC version 2018-12-28 14:36:23.08731647 [ThreadId 4] - Mismatching GHC versions: Project is No System GHC found, HIE is 8.6.3 2018-12-28 14:36:23.087376738 [ThreadId 4] - Run entered for HIE(hie) Version 0.4.0.1, Git revision 4f0c017 (dirty) (2286 commits) x86_64 ghc-8.6.3 2018-12-28 14:36:23.087474913 [ThreadId 4] - Current directory:/tmp/ff 2018-12-28 14:36:23.087594646 [ThreadId 4] -
1 parent b037cb7 commit 814aa51

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

app/HieWrapper.hs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,10 @@ run opts = do
8383

8484
let
8585
hieBin = "hie-" ++ ghcVersion
86-
backupHieBin = "hie-" ++ init (dropWhileEnd (/='.') ghcVersion)
86+
backupHieBin =
87+
case dropWhileEnd (/='.') ghcVersion of
88+
[] -> "hie"
89+
xs -> "hie-" ++ init xs
8790
candidates' = [hieBin, backupHieBin, "hie"]
8891
candidates = map (++ exeExtension) candidates'
8992

src/Haskell/Ide/Engine/Plugin/Base.hs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,22 +105,27 @@ hieGhcDisplayVersion = compilerName ++ "-" ++ VERSION_ghc
105105

106106
getProjectGhcVersion :: IO String
107107
getProjectGhcVersion = do
108-
isStackProject <- doesFileExist "stack.yaml"
108+
isStackProject <- doesFileExist "stack.yaml"
109109
isStackInstalled <- isJust <$> findExecutable "stack"
110110
if isStackProject && isStackInstalled
111111
then do
112112
L.infoM "hie" "Using stack GHC version"
113113
catch (tryCommand "stack ghc -- --numeric-version") $ \e -> do
114114
L.errorM "hie" $ show (e :: SomeException)
115115
L.infoM "hie" "Couldn't find stack version, falling back to plain GHC"
116-
tryCommand "ghc --numeric-version"
116+
getGhcVersion
117117
else do
118118
L.infoM "hie" "Using plain GHC version"
119-
tryCommand "ghc --numeric-version"
119+
getGhcVersion
120120

121121
where
122+
getGhcVersion = do
123+
isGhcInstalled <- isJust <$> findExecutable "ghc"
124+
if isGhcInstalled
125+
then tryCommand "ghc --numeric-version"
126+
else return "No System GHC found"
127+
122128
tryCommand cmd =
123-
-- Drop '\n' from the output like "7.10.3\n", "8.4.3\n"
124129
init <$> readCreateProcess (shell cmd) ""
125130

126131
hieGhcVersion :: String

0 commit comments

Comments
 (0)