Skip to content

Commit 03b992b

Browse files
authored
Merge pull request #36 from jneira/install-check-ghcs
Check there is one ghc in $PATH
2 parents 224928d + 9058d43 commit 03b992b

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

install/src/Cabal.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,6 @@ cabalInstallIsOldFailMsg cabalVersion =
114114
++ versionToString requiredCabalVersion
115115
++ "`."
116116

117-
118117
requiredCabalVersion :: RequiredVersion
119118
requiredCabalVersion | isWindowsSystem = requiredCabalVersionForWindows
120119
| otherwise = [2, 4, 1, 0]

install/src/Env.hs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,23 @@ findInstalledGhcs = do
6262
-- filter out stack provided GHCs (assuming that stack programs path is the default one in linux)
6363
$ filter (not . isInfixOf ".stack" . snd) (knownGhcs ++ availableGhcs)
6464

65+
showInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
66+
showInstalledGhcs ghcPaths = do
67+
let msg = "Found the following GHC paths: \n"
68+
++ unlines
69+
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
70+
ghcPaths
71+
)
72+
printInStars msg
73+
74+
checkInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
75+
checkInstalledGhcs ghcPaths = when (null ghcPaths) $ do
76+
let msg = "No ghc installations found in $PATH. \n"
77+
++ "The script requires at least one ghc in $PATH \n"
78+
++ " to be able to build haskell-language-server.\n"
79+
printInStars msg
80+
error msg
81+
6582
-- | Get the path to a GHC that has the version specified by `VersionNumber`
6683
-- If no such GHC can be found, Nothing is returned.
6784
-- First, it is checked whether there is a GHC with the name `ghc-$VersionNumber`.

install/src/HieInstall.hs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -88,22 +88,14 @@ defaultMain = do
8888
phony "haskell-language-server" (need ["data", "latest"])
8989

9090
-- stack specific targets
91-
when isRunFromStack $ do
92-
91+
when isRunFromStack $
9392
phony "dev" $ stackInstallHieWithErrMsg Nothing
9493

9594
-- cabal specific targets
9695
when isRunFromCabal $ do
97-
98-
phony "ghcs" $ do
99-
let
100-
msg =
101-
"Found the following GHC paths: \n"
102-
++ unlines
103-
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
104-
ghcPaths
105-
)
106-
printInStars msg
96+
-- It throws an error if there is no ghc in $PATH
97+
checkInstalledGhcs ghcPaths
98+
phony "ghcs" $ showInstalledGhcs ghcPaths
10799

108100
-- macos specific targets
109101
phony "icu-macos-fix"

0 commit comments

Comments
 (0)