Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I cant get the pg gem to install. I have tried --with-pg_config and it didnt work.

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
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.
share|improve this question

3 Answers 3

up vote 1 down vote accepted

Can't find the 'libpq-fe.h header

If you haven't done it already, install and initialize apt-file. This tool tells you what package contains a file with the given name.

sudo apt-get install apt-file
apt-file update

Then run apt-file search libpq-fe.h to find out what package contains this file, and install the package in question. (It's libpq-dev.)

You can also search for this file name in some package installation GUIs, or online.

share|improve this answer

The problem is likely due to missing postgresql development package. You can either install it manually or use the package manager from your distribution. Probably packages missing (install them with apt-get install):

  1. libpq-dev
  2. postgresql-server-dev-all

You can also try to install the ruby pg extension from your repository via apt-get install libpgsql-ruby

share|improve this answer

What worked for me was doing the following:

sudo apt-get install postgresql
sudo apt-get install libpq-dev

Then

bundle gem install pg

then

bundle install

src:

http://wikimatze.de/installing-postgresql-gem-under-ubuntu-and-mac

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.