Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
checking for PQconnectdb() in -lms/libpq... no
Can't find the PostgreSQL client library (libpq)
*** 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.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/home/nicholas/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config
    --with-pqlib
    --without-pqlib
    --with-libpqlib
    --without-libpqlib
    --with-ms/libpqlib
    --without-ms/libpqlib


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
add comment

3 Answers

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
add comment

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
add comment

I had the same problem.

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

share|improve this answer
add comment

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.