From 7e05c152198c03f2e33aece701af158eb939e0e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Gr=C3=B6ber?= Date: Wed, 11 May 2016 15:27:11 +0200 Subject: [PATCH] 'debug' shouldn't fail if 'cabal' is not installed which seems to be more common that you'd think --- Language/Haskell/GhcMod/Debug.hs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Language/Haskell/GhcMod/Debug.hs b/Language/Haskell/GhcMod/Debug.hs index 48f7137..59673e0 100644 --- a/Language/Haskell/GhcMod/Debug.hs +++ b/Language/Haskell/GhcMod/Debug.hs @@ -9,6 +9,7 @@ import qualified Data.Set as Set import Data.Char import Data.Version import Data.List.Split +import System.Directory import Text.PrettyPrint import Language.Haskell.GhcMod.Monad import Language.Haskell.GhcMod.Types @@ -76,8 +77,14 @@ cabalDebug = do srcOpts = Map.map gmcGhcSrcOpts mcs readProc <- gmReadProcess - cabalInstVersion <- liftIO $ - dropWhileEnd isSpace <$> readProc "cabal" ["--numeric-version"] "" + cabalExists <- liftIO $ (/=Nothing) <$> findExecutable "cabal" + + cabalInstVersion <- + if cabalExists + then liftIO $ + dropWhileEnd isSpace <$> readProc "cabal" ["--numeric-version"] "" + else return "" + packages <- liftIO $ readProc "ghc-pkg" ["list", "--simple-output"] "" let cabalPackages = filter ((== ["Cabal"]) . take 1 . splitOn "-") $ splitWhen isSpace packages