7

when running bundle install (or gem install pg) i get the following error i have already tried fixing the xcode command line tools

/Users/josh/.rvm/rubies/ruby-2.0.0-p353/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.
  • Ruby 2.0.0
  • Rails 4.0.2
  • OSX 10.9.1
  • A comprehensive answer is provided on https://stackoverflow.com/questions/19262312/installing-pg-gem-on-os-x-failure-to-build-native-extension/60039365#60039365. – Esmaeil MIRZAEE Feb 03 '20 at 12:37

3 Answers3

12

I just had this same problem today and this answer solved it for me.

https://stackoverflow.com/a/19620569/91970

Hope that helps.

Summary

brew update

brew install postgresql

bundle install

Community
  • 1
  • 1
marcamillion
  • 32,933
  • 55
  • 189
  • 380
5

For reference, the code @marcamillion is linking to:

brew update
brew install postgresql

bundle install
Fellow Stranger
  • 32,129
  • 35
  • 168
  • 232
3

I had the same problem .. I've modified Gemfile.lock and replaced pg (0.17.1) with pg(0.18.1) only.

Download PostgreSQL 9.4 and installed in system

use following command to install pg now

gem install pg -- --with-pg-config=/Applications/Postgres.app/Contents/Versions/9.4/bin/pg_config
Vinod Joshi
  • 7,696
  • 1
  • 50
  • 51