1

I have the following problem when trying to install the pg gem. My OS is Ubuntu 12.10. I've already installed postgresql (via the installer from the postgres page). I've also done apt-get install of libpq5 and libpq-dev. This is the error:

ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/sauronnikko/.rvm/rubies/ruby-1.9.3-p385/bin/ruby extconf.rb
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/sauronnikko/.rvm/rubies/ruby-1.9.3-p385/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

Can you help me? Thanks

Chris Travers
  • 25,424
  • 6
  • 65
  • 182
sauronnikko
  • 4,665
  • 5
  • 31
  • 47
  • $ gem install pg -- --with-pg-config=/usr/pgsql-9.2/bin/pg_config would be help I think. However --with-pg-config path is depending on which version of postgres you installed. – diveintohacking Feb 16 '13 at 18:24
  • it gave me the same error. I believe it actually has been finding `pg_config` all along, because it always says `checking for pg_config... yes`, so I think it's something else that's wrong – sauronnikko Feb 16 '13 at 18:48
  • 1
    Or does this [Q&A](http://stackoverflow.com/questions/4393189/failing-installing-pg-gem-mkmf-rb-cant-find-header-files-for-ruby-mac-osx-1) help for you? – diveintohacking Feb 16 '13 at 18:51
  • 1
    Yes, it was most helpful. Running gem install like this did the trick: `gem install pg -- --with-pg-lib=/opt/PostgreSQL/9.2/lib --with-pg-include=/opt/PostgreSQL/9.2/include`. Thank you – sauronnikko Feb 16 '13 at 19:00

1 Answers1

4
sudo apt-get install postgresql libpq-dev

then

bundle install

see this page: Rails 3 - can't install pg gem

Sebastián Palma
  • 32,692
  • 6
  • 40
  • 59
Zakaria
  • 983
  • 15
  • 24