Skip to content

Commit

Permalink
Merge pull request #209 from amosr/topic/recover-build-tool-failure
Browse files Browse the repository at this point in the history
Continue building after failing to install build-tool
  • Loading branch information
erikd authored Mar 9, 2018
2 parents 8f117f6 + 60726b8 commit 0144942
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Mafia/Install.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 0144942

Please sign in to comment.