diff --git a/Language/Haskell/GhcMod/CabalHelper.hs b/Language/Haskell/GhcMod/CabalHelper.hs index 0fa2fee..af85eff 100644 --- a/Language/Haskell/GhcMod/CabalHelper.hs +++ b/Language/Haskell/GhcMod/CabalHelper.hs @@ -242,8 +242,8 @@ withCabal action = do supported <- haveStackSupport if supported then do - spawn [T.stackProgram progs, "build", "--only-dependencies"] - spawn [T.stackProgram progs, "build", "--only-configure"] + spawn [T.stackProgram progs, "build", "--only-dependencies", "."] + spawn [T.stackProgram progs, "build", "--only-configure", "."] writeAutogen projdir distdir else gmLog GmWarning "" $ strDoc $ "Stack project configuration is out of date, please reconfigure manually using 'stack build' as your stack version is too old (need at least 0.1.4.0)" diff --git a/Language/Haskell/GhcMod/PathsAndFiles.hs b/Language/Haskell/GhcMod/PathsAndFiles.hs index 47dc090..13649c0 100644 --- a/Language/Haskell/GhcMod/PathsAndFiles.hs +++ b/Language/Haskell/GhcMod/PathsAndFiles.hs @@ -20,6 +20,7 @@ module Language.Haskell.GhcMod.PathsAndFiles ( ) where import Config (cProjectVersion) +import Control.Arrow (second) import Control.Applicative import Control.Exception as E import Control.Monad @@ -77,7 +78,12 @@ findCabalFile dir = do appendDir d fs = (d ) `map` fs findStackConfigFile :: FilePath -> IO (Maybe FilePath) -findStackConfigFile dir = mightExist (dir "stack.yaml") +findStackConfigFile dir = do + fs <- map (second listToMaybe) <$> findFileInParentsP (=="stack.yaml") dir + case find (isJust . snd) fs of + Nothing -> return Nothing + Just (d, Just a) -> return $ Just $ d a + Just (_, Nothing) -> error "findStackConfigFile" getStackDistDir :: (IOish m, GmOut m) => FilePath -> m (Maybe FilePath) getStackDistDir projdir = U.withDirectory_ projdir $ runMaybeT $ do @@ -165,7 +171,7 @@ takeExtension' p = -- it's parent directories. findFileInParentsP :: (FilePath -> Bool) -> FilePath -> IO [(DirPath, [FileName])] -findFileInParentsP p dir = +findFileInParentsP p dir' = makeAbsolute dir' >>= \dir -> getFilesP p `zipMapM` parents dir -- | @getFilesP p dir@. Find all __files__ satisfying @p@ in @.cabal@ in @dir@.