mherzl
mherzl

Reputation: 6210

setup: The program 'pg_config' is required but it could not be found

On nixos, when attempting to build my project with $ stack --nix build, I run into the following error.

$ stack --nix build

...

Linking /run/user/1000/stack25943/postgresql-libpq-0.9.2.0/.stack-work/dist/x86_64-linux-nix/Cabal-1.24.2.0/setup/setup ...
Configuring postgresql-libpq-0.9.2.0...
setup: The program 'pg_config' is required but it could not be found.

I have installed postgres following the nixos manual and do have pg_config installed, as shown by

$ which pg_config
/run/current-system/sw/bin/pg_config

It appears that stack does not know this location of my pg_config.

How do I proceed to get $ stack --nix build to succeed?

Upvotes: 5

Views: 3709

Answers (2)

Bedi Egilmez
Bedi Egilmez

Reputation: 1542

If you're getting this on mac, run brew install postgres then stack build

Upvotes: 5

iElectric
iElectric

Reputation: 5819

You'll need to add Nix packages to the nix-shell environment that it's building Haskell packages in.

In stack.yaml:

nix:
  packages: [postgresql]

Upvotes: 6

Related Questions