Skip to content

Bail out of install if stack is not installed #257

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
Jul 10, 2017
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
6 changes: 6 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,12 @@ do_setup() {
ARG_NO_HELPER_BINS=
fi

if ! check_exist stack >/dev/null ; then
err "Installer requires Stack."
msg "Installation instructions: http://docs.haskellstack.org/en/stable/README/#how-to-install"
exit 1
fi

stack $setup_haskell_path $ARG_NO_HOOGLE_DB $ARG_NO_HELPER_BINS ; RETCODE=$?
[ ${RETCODE} -ne 0 ] && exit_err "setup_haskell.hs failed with error ${RETCODE}."
fi
Expand Down
12 changes: 1 addition & 11 deletions scripts/setup_haskell.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,11 +94,6 @@ setup = do
setupHaskell :: (MonadIO m, MonadReader HvnConfig m) => m ()
setupHaskell = do
HvnConfig {hvnCfgDest, hvnCfgHoogleDb, hvnCfgHelperBinaries} <- ask
hasStack <- hasExecutable "stack"
unless hasStack $ do
err "Installer requires Stack - installation instructions:"
err " http://docs.haskellstack.org/en/stable/README/#how-to-install"
Turtle.exit (Turtle.ExitFailure 1)
msg "Setting up GHC if needed..."
stackSetupResult <- Turtle.shell "stack setup --verbosity warning" empty
case stackSetupResult of
Expand Down Expand Up @@ -233,6 +228,7 @@ stackInstall resolver package = do
let installCommand =
"stack --resolver " <> resolver <> " install " <> package <>
" --install-ghc --verbosity warning"
detail installCommand
installResult <- Turtle.shell installCommand empty
case installResult of
(Turtle.ExitFailure retCode) -> do
Expand Down Expand Up @@ -329,12 +325,6 @@ commandSubstitution cmd = do
mval <- Turtle.fold (Turtle.inshell cmd empty) Foldl.head
pure $ maybe mempty Turtle.lineToText mval

hasExecutable :: (MonadIO m) => FilePath -> m Bool
hasExecutable exeName = do
path <- runMaybeT $ MaybeT (Turtle.which (FS.addExtension exeName "exe"))
<|> MaybeT (Turtle.which exeName)
pure . isJust $ path

-- For Unix, could use System.Posix.Files createSymbolicLink instead of raw
-- shell.
mkDirLink :: (MonadIO m) => FilePath -> FilePath -> m ()
Expand Down