Build error installing yesod-bin

Hello, I wanted to experiment with web development in Haskell and I decided to try out the yesod framework, however following the suggested steps:

stack new my-project yesodweb/simple
cd my-project
stack install yesod-bin --install-ghc

the build process fails with the following error:

Error: [S-7282]
       Stack failed to execute the build plan.

       While executing the build plan, Stack encountered the error:

       [S-7011]
       While building package zlib-0.6.3.0 (scroll up to its section to see the error)

with the zlib logs being:

zlib              > configure
zlib              > Configuring zlib-0.6.3.0...
zlib              > Cabal-simple_w2MFVN35_3.6.3.0_ghc-9.2.8: Missing dependency on a foreign
zlib              > library:
zlib              > * Missing (or bad) header file: zlib.h
zlib              > * Missing (or bad) C library: z
zlib              > This problem can usually be solved by installing the system package that
zlib              > provides this library (you may need the "-dev" version). If the library is
zlib              > already installed but in a non-standard location then you can use the flags
zlib              > --extra-include-dirs= and --extra-lib-dirs= to specify where it is.If the
zlib              > library file does exist, it may contain errors that are caught by the C
zlib              > compiler at the preprocessing stage. In this case you can re-run configure
zlib              > with the verbosity flag -v3 to see the error messages.
zlib              > If the header file does exist, it may contain errors that are caught by the C
zlib              > compiler at the preprocessing stage. In this case you can re-run configure
zlib              > with the verbosity flag -v3 to see the error messages.

I’m currently on Fedora 42 with the zlib library and its development version provided by the package zlib-ng and the zlib.h file in the standard location /usr/include hence I’m unsure of the cause of this error, any suggestion or help would be greatly appreciated.

2 Likes

Not sure what the fedora package name would be but you also need the ghc to zlib bindings.

1 Like

I do not know if this will help, but zlib-0.6.3.0 has a Cabal flag pkg-config that is disabled by default that is “Use pkg-config(1) to locate foreign zlib library.”.

Perhaps in your Stack project-level configuration file (stack.yaml) you need something like:

flags:
  zlib:
    pkg-config: true

I am Windows user, so can’t really help with Fedora 42.

BTW the Fedora stack package pulls in zlib-devel by default, but the version is lagging due to dependency requirements - Fedora 43 will have the latest stack-3.7 at least :slight_smile:
(As does the Fedora cabal-install package.
Well to be precise it’s a weak dependency (recommends).)

Anyway you can just run sudo dnf install zlib-devel to pull it in yourself.
(These days it is actually provided by zlib-ng-compat-devel.)

If that still doesn’t help, please ask more.

However for simple experimenting you could even just use the Fedora Haskell packages directly: yesod and everything is already built in Fedora (dnf install ghc-yesod-devel, etc) though using cabal-install and newer ghc-9.6.

1 Like

zlib-0.6.3.0 is fairly old. Try putting an override into stack.yaml with

extra-deps:
- zlib-0.7.1.0

If it still does not work, raise an issue at GitHub · Where software is built please.