0

I am running Mac OSX 10.9.4, rails 4

I am trying to add Postgresql to a rails app to deploy to heroku. However, I cannot seem to bundle install it. And when i tried:

rails new myapp -d postgresql

that also does not work. I keep getting the following error message:

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/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=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
  --with-pg
  --without-pg
  --with-pg-config
  --without-pg-config
  --with-pg_config
  --without-pg_config
  --with-pg-dir
  --without-pg-dir
  --with-pg-include
  --without-pg-include=${pg-dir}/include
  --with-pg-lib
  --without-pg-lib=${pg-dir}/

extconf failed, exit code 1

Gem files will remain installed in /var/folders/_1/ppbm8m0x66x0bfm0xv3nd_300000gn/T/bundler20140801-11374-yfgvap/pg-0.17.1/gems/pg-0.17.1 for inspection.
Results logged to /var/folders/_1/ppbm8m0x66x0bfm0xv3nd_300000gn/T/bundler20140801-11374-yfgvap/pg-0.17.1/extensions/universal-darwin-13/2.0.0/pg-0.17.1/gem_make.out
An error occurred while installing pg (0.17.1), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.1'` succeeds before bundling.
         run  bundle exec spring binstub --all
/Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/resolver.rb:352:in `resolve': Could not find gem 'pg (>= 0) ruby' in the gems available on this machine. (Bundler::GemNotFound)
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/resolver.rb:165:in `start'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/resolver.rb:129:in `resolve'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/definition.rb:203:in `resolve'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/definition.rb:133:in `specs'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/definition.rb:178:in `specs_for'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/definition.rb:167:in `requested_specs'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/environment.rb:18:in `requested_specs'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/runtime.rb:13:in `setup'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler.rb:120:in `setup'
  from /Library/Ruby/Gems/2.0.0/gems/bundler-1.6.2/lib/bundler/setup.rb:17:in `<top (required)>'
  from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'

can someone help me out. Thanks.

itzmurd4
  • 663
  • 10
  • 25
  • how did you install postgresql on your mac? are you using the Postgres.app ? or did you do it through homebrew, etc.? – derekyau Aug 01 '14 at 19:33
  • possible duplicate of [Can't find the 'libpq-fe.h header when trying to install pg gem](http://stackoverflow.com/questions/6040583/cant-find-the-libpq-fe-h-header-when-trying-to-install-pg-gem) – infused Aug 01 '14 at 19:35
  • I ran into the same issue after installing PostgreSQL via the Postgres.app. Running `gem install pg -v '0.17.1'` fixed the issue for me, and I'm also on Mac OSX 10.9.4, rails 4. – digijim Aug 01 '14 at 19:44
  • i use postgresql.app by heroku. it is awesome. – Paritosh Piplewar Aug 01 '14 at 20:27

0 Answers0