Skip to content

Check there is one ghc in $PATH #36

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion install/src/Cabal.hs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,6 @@ cabalInstallIsOldFailMsg cabalVersion =
++ versionToString requiredCabalVersion
++ "`."


requiredCabalVersion :: RequiredVersion
requiredCabalVersion | isWindowsSystem = requiredCabalVersionForWindows
| otherwise = [2, 4, 1, 0]
Expand Down
17 changes: 17 additions & 0 deletions install/src/Env.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,23 @@ findInstalledGhcs = do
-- filter out stack provided GHCs (assuming that stack programs path is the default one in linux)
$ filter (not . isInfixOf ".stack" . snd) (knownGhcs ++ availableGhcs)

showInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
showInstalledGhcs ghcPaths = do
let msg = "Found the following GHC paths: \n"
++ unlines
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
ghcPaths
)
printInStars msg

checkInstalledGhcs :: MonadIO m => [(VersionNumber, GhcPath)] -> m ()
checkInstalledGhcs ghcPaths = when (null ghcPaths) $ do
let msg = "No ghc installations found in $PATH. \n"
++ "The script requires at least one ghc in $PATH \n"
++ " to be able to build haskell-language-server.\n"
printInStars msg
error msg

-- | Get the path to a GHC that has the version specified by `VersionNumber`
-- If no such GHC can be found, Nothing is returned.
-- First, it is checked whether there is a GHC with the name `ghc-$VersionNumber`.
Expand Down
16 changes: 4 additions & 12 deletions install/src/HieInstall.hs
Original file line number Diff line number Diff line change
Expand Up @@ -88,22 +88,14 @@ defaultMain = do
phony "haskell-language-server" (need ["data", "latest"])

-- stack specific targets
when isRunFromStack $ do

when isRunFromStack $
phony "dev" $ stackInstallHieWithErrMsg Nothing

-- cabal specific targets
when isRunFromCabal $ do

phony "ghcs" $ do
let
msg =
"Found the following GHC paths: \n"
++ unlines
(map (\(version, path) -> "ghc-" ++ version ++ ": " ++ path)
ghcPaths
)
printInStars msg
-- It throws an error if there is no ghc in $PATH
checkInstalledGhcs ghcPaths
phony "ghcs" $ showInstalledGhcs ghcPaths

-- macos specific targets
phony "icu-macos-fix"
Expand Down