From 60726b8e7ec8f6cb7b2756ded8b1d38ff4813d8d Mon Sep 17 00:00:00 2001 From: Amos Robinson Date: Fri, 9 Mar 2018 08:55:25 +1100 Subject: [PATCH] Continue building after failing to install build-tool Some packages refer to build-tools that are not cabal packages. For example, "zip-archive" depends on "unzip", but this is talking about a binary, not a cabal package. This is unfortunate, and perhaps the package shouldn't include this as it isn't a build tool, but we should probably provide some way to continue building regardless. --- src/Mafia/Install.hs | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Mafia/Install.hs b/src/Mafia/Install.hs index d52c6ac..8b7f36a 100644 --- a/src/Mafia/Install.hs +++ b/src/Mafia/Install.hs @@ -379,12 +379,28 @@ installBuildTools :: CacheEnv -> Set BuildTool -> EitherT InstallError IO [Direc installBuildTools env tools = do pkgs <- for (Set.toList tools) $ \(BuildTool name constraints) -> - installPackage name constraints + tryInstall name constraints pure . fmap ( "bin") . fmap (packageSandboxDir env) $ - fmap pkgKey pkgs + fmap pkgKey $ + catMaybes pkgs + where + -- Some packages refer to build-tools that are not cabal packages. + -- For example, "zip-archive" depends on "unzip", but this is talking about a binary, not a cabal package. + -- This is unfortunate, and perhaps the package shouldn't include this as it isn't a build tool, but we should probably provide some way to continue building regardless. + tryInstall name constraints = EitherT $ do + r <- runEitherT $ installPackage name constraints + case r of + Left e -> do + T.hPutStrLn stderr $ + "Error while trying to install build tool '" <> unPackageName name <> "': " + T.hPutStrLn stderr $ renderInstallError e + T.hPutStrLn stderr "Trying to continue anyway, as some packages refer to non-existent build tools." + return $ Right Nothing + Right pkg -> do + return $ Right $ Just pkg -- | Detect the build tools required by a package. detectBuildTools :: Package -> EitherT InstallError IO (Set BuildTool)