Haskell stack build error: While building package postgresql-libpq-0.9.4.3

Viewed 542

I added - postgresql-simple to the dependencies on package.yaml of my Haskell stack project and then did stack build and got:

While building package postgresql-libpq-0.9.4.3 (scroll up to its section to see the error) using:
      /tmp/stack-89da86d626e343e1/postgresql-libpq-0.9.4.3/.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0/setup/setup --builddir=.stack-work/dist/x86_64-linux-tinfo6/Cabal-3.2.1.0 configure --user --package-db=clear --package-db=global --package-db=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/pkgdb --libdir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/lib --bindir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/bin --datadir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/share --libexecdir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/libexec --sysconfdir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/etc --docdir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/doc/postgresql-libpq-0.9.4.3 --htmldir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/doc/postgresql-libpq-0.9.4.3 --haddockdir=/root/.stack/snapshots/x86_64-linux-tinfo6/08a30a38364a81e94295cf97609a35ddfc240f67779f06f0eb2ce22d8a89e805/8.10.4/doc/postgresql-libpq-0.9.4.3 --dependency=Cabal=Cabal-3.2.1.0 --dependency=base=base-4.14.1.0 --dependency=bytestring=bytestring-0.10.12.0 --dependency=unix=unix-2.7.2.2 -f-use-pkg-config --exact-configuration --ghc-option=-fhide-source-paths
    Process exited with code: ExitFailure 1

The container has protgresql installed like this:

RUN apt-get update && apt-get install -y wget lsb-release

RUN sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

RUN wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add -

RUN apt-get update && apt-get -y install postgresql

and pg_config works.

Even though it says scroll up to its section to see the error there are no errors above.

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

this was at the very top of the log

After reading that and doing sudo apt install -y libpq-dev and then stack build again it worked

Related