[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now


PostgreSQL ruby pg gem not installing

Posted on 2012-09-21
Medium Priority
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: http://linuxpoison.blogspot.com/2012/01/how-to-install-configure-postgresql.html

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

Author Comment

ID: 38423357
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

ID: 38423490
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

ID: 38423638
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

olivergwald earned 0 total points
ID: 38423822
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

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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
When you discover the power of the R programming language, you are going to wonder how you ever lived without it! Learn why the language merits a place in your programming arsenal.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Screencast - Getting to Know the Pipeline

834 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