-2

On Mac OS X 10.6.8, I get the following error when trying gem install pg. Trying to push my Rails website to Heroku. A pretty standard install of Ruby 1.9.3p194.

$ cat /Users/me/.rvm/gems/ruby-1.9.3-p194\@ucode/gems/pg-0.15.1/ext/gem_make.out 
/Users/me/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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
    --without-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=/Users/me/.rvm/rubies/ruby-1.9.3-p194/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

I've never needed to install postgresql locally before. Do I need to install the database too? In fact I don't even plan to ever use postgresql locally, just on Heroku

  • 3
    "I don't even plan to ever use postgresql locally" is a really bad idea, developing and deploying with different databases is a very common source of pain and suffering. And no, an ORM such as ActiveRecord will not insulate you from database differences. So install PostgreSQL locally and develop using PostgreSQL if you're planning on deploying on top of PostgreSQL. – mu is too short May 22 '13 at 22:50
  • possibly [duplicated](http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem-on-ubuntu?rq=10) – fotanus May 22 '13 at 23:38
  • The gem has a native C extension which needs the PostgreSQL (PGSQL) header files that come with a PGSQL installation. I highly doubt that you didn't need to install PGSQL before, maybe you had it installed without knowing. Installation with Homebrew is dead simple: `brew install postgresql` and follow the instructions on screen. – Patrick Oscity May 23 '13 at 14:04

1 Answers1

2

The first line of the build output tells you what's wrong and what to do:

No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config

So.... pass --with-pg-config=/wherever/your/pg_config or add it to the PATH so the build can find it.

I strongly second mu's comment, too; testing locally with one DB and remotely with another is a recipe for pain, suffering, and deploy errors. It would be lovely if SQL was really consistent and standard enough for that to work, but the reality is different.

Craig Ringer
  • 307,061
  • 76
  • 688
  • 778