Haskell stack "While building package" in CI
stack invoked the build for a package and the underlying GHC/Setup process exited non-zero. The "While building package" banner identifies which package failed; the real compiler error is in the logged output above it.
What this error means
stack build stops with "While building package X-1.2.3 ..." and "Process exited with code: ExitFailure (1)", preceded by a GHC error or a missing system dependency.
-- While building package zlib-0.6.3.0 using:
/root/.stack/setup-exe-cache/.../Cabal-simple ... build --ghc-options ...
Process exited with code: ExitFailure 1
zlib.h: No such file or directoryCommon causes
A missing system library for a package with C bindings
Packages like zlib or postgresql-libpq need their -dev system libraries; a slim runner image omits them, so the build fails.
A compile error in the package being built
A GHC type or scope error in your package or a dependency caused the build process to exit non-zero.
How to fix it
Install the system dependency the build names
- Read the GHC/C error above the "While building package" banner.
- Install the missing
-devsystem library before stack. - Re-run
stack build.
sudo apt-get update
sudo apt-get install -y zlib1g-dev libpq-devReproduce and fix the compile error locally
Build the failing package alone so the GHC error is isolated, then fix the code or pin a working version.
stack build zlib --verboseHow to prevent it
- Install required
-devsystem libraries before stack build. - Cache
~/.stackand.stack-workso builds are incremental. - Pin a resolver so the dependency set is reproducible.