4

I'm trying to install the pg gem with a new rails app, but I keep receiving the same error:

Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /home/arthur/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb --with-pg-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.

I've already tried everything from this question: How to install PostgreSQL's pg gem on Ubuntu? but nothing really worked for me.

That's ruby 1.9.2 and Rails 3.2, by the way.

Thanks

Community
  • 1
  • 1
Arthur Camara
  • 578
  • 8
  • 19
  • Check this [link][1], hope it helps. [1]: http://stackoverflow.com/questions/6209797/cant-find-the-postgresql-client-library-libpq – Rodrigo Oliveira Nov 07 '12 at 19:08
  • please append the ruby and rails version in your post. – tokhi Nov 07 '12 at 19:24
  • Have you checked the mkmf.log as the output suggests? What does it say? – davidrac Nov 07 '12 at 19:41
  • Rodrigo, it didnt helped. stsd, just edited the post. Sorry about that. davidrac, There is no mkmf.log file on any folder related to the pg gem. Any idea on where it should be located? – Arthur Camara Nov 07 '12 at 19:46
  • 1
    Check that the file `/usr/include/postgresql/libpq-fe.h` exists and exports the function `PQconnectdb`. – cdesrosiers Nov 07 '12 at 20:16
  • 1
    You need install postgresql in local development, run `sudo apt-get install postgresql-9.1` and try install `pg` gem again. – Thanh Nov 08 '12 at 05:58

1 Answers1

1

Install postgresql 9 and then install your gem.

sudo apt-get install postgresql libpq-dev

Now, run

gem install pg

and then

bundle install

Pranjal Nadhani
  • 106
  • 1
  • 5