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

Commit 0d6aeae

Browse files
authored
Merge pull request #1344 from power-fungus/install-fail-on-old-cabal-install
fail installation if cabal-version is too low
2 parents c1f58e4 + 6b5776e commit 0d6aeae

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

install/src/Cabal.hs

+9-9
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ import Development.Shake
44
import Development.Shake.Command
55
import Development.Shake.FilePath
66
import Control.Monad
7-
import Data.Maybe ( isNothing )
7+
import Data.Maybe ( isNothing
8+
, isJust
9+
)
810
import Control.Monad.Extra ( whenMaybe )
911
import System.Directory ( findExecutable
1012
, copyFile
@@ -56,20 +58,18 @@ cabalInstallHie versionNumber = do
5658
installCabal :: Action ()
5759
installCabal = do
5860
-- try to find existing `cabal` executable with appropriate version
59-
cabalExe <- liftIO (findExecutable "cabal") >>= \case
60-
Nothing -> return Nothing
61-
Just cabalExe -> do
62-
cabalVersion <- trimmedStdout <$> execCabal ["--numeric-version"]
63-
whenMaybe (checkVersion requiredCabalVersion cabalVersion)
64-
$ return cabalExe
61+
cabalExeOk <- do
62+
c <- liftIO (findExecutable "cabal")
63+
when (isJust c) checkCabal
64+
return $ isJust c
6565

6666
-- install `cabal-install` if not already installed
67-
when (isNothing cabalExe) $ execStackShake_ ["install", "cabal-install"]
67+
unless cabalExeOk $ execStackShake_ ["install", "cabal-install"]
6868

6969
-- | check `stack` has the required version
7070
checkCabal :: Action ()
7171
checkCabal = do
72-
cabalVersion <- trimmedStdout <$> execCabal ["--numeric-version"]
72+
cabalVersion <- getCabalVersion
7373
unless (checkVersion requiredCabalVersion cabalVersion) $ do
7474
printInStars $ cabalInstallIsOldFailMsg cabalVersion
7575
error $ stackExeIsOldFailMsg cabalVersion

0 commit comments

Comments
 (0)