diff --git a/install/src/Cabal.hs b/install/src/Cabal.hs index 171cb7667..72fd00b04 100644 --- a/install/src/Cabal.hs +++ b/install/src/Cabal.hs @@ -113,7 +113,6 @@ cabalInstallIsOldFailMsg cabalVersion = ++ versionToString requiredCabalVersion ++ "`." - requiredCabalVersion :: RequiredVersion requiredCabalVersion | isWindowsSystem = requiredCabalVersionForWindows | otherwise = [2, 4, 1, 0] diff --git a/install/src/Env.hs b/install/src/Env.hs index 037e51bc9..83c23b0fc 100644 --- a/install/src/Env.hs +++ b/install/src/Env.hs @@ -62,6 +62,22 @@ 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 to be able to build hie.\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`. diff --git a/install/src/HieInstall.hs b/install/src/HieInstall.hs index a5cc1fafa..d46e2bffe 100644 --- a/install/src/HieInstall.hs +++ b/install/src/HieInstall.hs @@ -78,34 +78,27 @@ defaultMain = do (\version -> phony ("hie-" ++ version) $ do need ["submodules"] need ["check"] - if isRunFromStack then do + if isRunFromStack then stackInstallHieWithErrMsg (Just version) else cabalInstallHie version ) - - phony "latest" (need ["hie-" ++ latestVersion]) - phony "hie" (need ["data", "latest"]) + + unless (null versions) $ do + phony "latest" (need ["hie-" ++ latestVersion]) + phony "hie" (need ["data", "latest"]) -- stack specific targets -- Default `stack.yaml` uses ghc-8.8.2 and we can't build hie in windows -- TODO: Enable for windows when it uses ghc-8.8.3 - when (isRunFromStack && not isWindowsSystem) $ do - + when (isRunFromStack && not isWindowsSystem) $ 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"