Take the 2-minute tour ×

I am trying to get Ruby on Rails working on my computer but the pg gem keeps failing. I have found a lot of other questions saying that you just need to use the libpq-dev package from apt and that should fix it but it is still saying that it can't find the library.

nicholas@nick-ubuntu:~$ gem instal pg -- --with-pq-lib=/usr/lib
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/nicholas/.rvm/rubies/ruby-1.9.3-p327/bin/ruby extconf.rb --with-pq-lib=/usr/lib
checking for pg_config... yes
Using config values from /usr/bin/pg_config
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for pg_config_manual.h... yes
checking for PQconnectdb() in -lpq... no
checking for PQconnectdb() in -llibpq... no
Can't find the PostgreSQL client library (libpq)
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
details.  You may need configuration options.

Provided configuration options:

Gem files will remain installed in /home/nicholas/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.14.1 for inspection.
Results logged to /home/nicholas/.rvm/gems/ruby-1.9.3-p327/gems/pg-0.14.1/ext/gem_make.out
share|improve this question

3 Answers 3

Awhile back, I found I had to use the ruby-pg gem instead of the pg gem, which was unneeded. Also, avoid the old postgres gem.

share|improve this answer

Try installing the following packages:

postgresql and libpq-dev.

That gets the pg gem to compile the native extensions for me on 11.10, 12.04 and 12.10.

share|improve this answer

I had the same problem.

Installing postgresql and libpq-dev did the trick for me too.

share|improve this answer

Your Answer


