PostgreSQL ruby pg gem not installing

Posted on 2012-09-21
Last Modified: 2013-01-22
gem install pg

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

        /home/ogottwald/.rvm/rubies/ruby-1.9.3-p194/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:

Gem files will remain installed in /home/ogottwald/.rvm/gems/ruby-1.9.3-p194@cm/gems/pg-0.14.1 for inspection.
Results logged to /home/ogottwald/.rvm/gems/ruby-1.9.3-p194@cm/gems/pg-0.14.1/ext/gem_make.out

The I'm honestly at a complete loss on this one.

I have tried everything under the sun.  I used the following to configure PostgreSQL:

I'm totally puzzled I've tried 15 to 20 things to get it working
Question by:olivergwald

    Author Comment

    I think it is either a permission (most likely) or path issue.

    Things I've tried:

    sudo apt-get libpg-dev

    gem install pg -- --with-pg-lib=/var/lib/postgresql/9.1/main
    Permission issue
    I think this is where the pg libs are.

    sudo apt-get install bundle-install

    locate pg_config

    gem install pg -- --with-pg-config=/usr/bin/pg_config

    It works with sudo gem install pg but the problem is i need non-root for rvm

    so i'm really confused on what to do

    Author Comment

    Now after all the above i did a /bundle install on my Gemfile and magically it is working.  But by itself with

    gem install pg

    it is not working.  Uh Uh Oh its magic...  you know...
    in my gemFile I have the following:

    platforms :mri, :mingw do
      group :postgresql do
        gem "pg"

      group :sqlite do
        gem "sqlite3"

    Author Comment

    I spoke to soon on this...
    so now I do rails s and get the following error:

    `require': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (cannot load such file -- pg_ext) (LoadError)

    So something is not cool

    Accepted Solution

    Okay what I ended up happening to do is a complete remove of the rvm

    reinstall the rvm
    configure rails etc..

    and then it started working
    something environmentally got messed up on my end.
    LVL 53

    Expert Comment

    This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    This is an explanation of a simple data model to help parse a JSON feed
    A short article about problems I had with the new location API and permissions in Marshmallow
    Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now