diff --git a/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs b/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs index 74269211561..b4712090371 100644 --- a/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs +++ b/cabal-install/src/Distribution/Client/ProjectBuilding/UnpackedPackage.hs @@ -681,7 +681,7 @@ buildAndInstallUnpackedPackage hooksDir <- ( "cabalHooks") <$> getCurrentDirectory -- run preBuildHook. If it returns with 0, we assume the build was -- successful. If not, run the build. - code <- + void $ rawSystemExitCode verbosity (Just srcdir) @@ -691,9 +691,12 @@ buildAndInstallUnpackedPackage , (getSymbolicPath builddir) ] Nothing - `catchIO` (\_ -> return (ExitFailure 10)) - when (code /= ExitSuccess) $ do - runBuild + `catchIO` (\_ -> pure (ExitFailure 10)) + -- Regardless of whether the preBuildHook exists or not, or whether it returned an + -- error or not, we want to run the post build. + -- If the preBuildHook downloads a cached version of the build products, the following + -- should be a NOOP. + runBuild -- not sure, if we want to care about a failed postBuildHook? void $ rawSystemExitCode @@ -705,7 +708,7 @@ buildAndInstallUnpackedPackage , (getSymbolicPath builddir) ] Nothing - `catchIO` (\_ -> return (ExitFailure 10)) + `catchIO` (\_ -> pure (ExitFailure 10)) PBHaddockPhase{runHaddock} -> do noticeProgress ProgressHaddock runHaddock