small medium large xlarge

28 Apr 2017, 01:46
Jon Guenther (4 posts)

The book nicely addresses a potential error installing the pg gem. While obviously the book can’t address every scenario, for anyone that follows the install guide for PostgreSQL 9.5 on Linux, you may still get an error making a new rails app:

Can't find the 'libpq-fe.h header
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

I ran into this error as I do a lot of my dev on cloud dev servers like Cloud9 and Codeanywhere, which spin up VMs with some earlier versions of Postgres installed than called for by David’s text.

To correct the above issue you can run:

sudo apt-get install libpq-dev

Then you should then be able to proceed with:

gem install pg

Hope this helps some/all that might encounter the issue.

29 Apr 2017, 15:19
David Copeland (436 posts)

Thanks for posting this. Installing native gems is a huge pain in Ruby,so any info that helps people is awesome!

You must be logged in to comment