Search code examples
ruby-on-railspostgresqlosx-mountain-lionpg

Missing PG headers ( trying to install Postgres gem for Rails with Brew )


checking for libpq-fe.h... *** extconf.rb failed ***

Seems to be the issue, it's from this tail:

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

        /Users/elephanttrip/.rvm/rubies/ruby-1.9.2-p320/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
checking for libpq-fe.h... *** 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.

My steps to reproduce this on a Mountain Lion Mac OS is :

  1. brew install postgresql
  2. env ARCHFLAGS="-arch x86_64" gem install pg

I've tried to pinpoint different pg_config's through my computer. The one in Brew's cellar, the one cp'd by Brew to /user/local, and another one that might have been from a previous download of it. None of them work.

UPDATE

Just tried to install without the config-options. And got an lol:

ruby extconf.rb --without-pg-config
checking for pg_config... yes

Solution

  • I started imagining that my issue had something to do with RVM as the bottom of the trace it said.. :

    "You need to download development tools"
    

    Then I did :

    $ rvm autolibs enable
    $ rvm requirements
    

    Then I went ahead and just updated my ruby ( if you don't do this, then I recommend just reinstalling it your current one. I could not do this without autolibs enable ) :

    $ rvm install ruby-2.0.0-p0
    

    Boom! Solved!!!! (:D :D :D :D :D) x 1,000,000