1
votes

I've looked all the solutions in the internet for this, reinstalled everything and still nothing... When i do gem install pg i get:

Building native extensions. This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension.

  /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb --with-pgsql->lib=/usr/local/Cellar/postgresql/9.2.1/lib --with-pg->config=/usr/local/Cellar/postgresql/9.2.1/bin/pg_config

Using config values from /usr/local/Cellar/postgresql/9.2.1/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.

Provided configuration options: --with-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/henriquedubugras/.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 /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:381:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:506:intry_cpp' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:970:in block in find_header' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:790:inblock in checking_for' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in block (2 levels) in postpone' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:284:in block in postpone' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:254:inopen' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:280:in postpone' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:789:inchecking_for' from /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/mkmf.rb:969:in find_header' from extconf.rb:41:in'

Gem files will remain installed in /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/pg-0.14.1 for inspection. Results logged to /Users/henriquedubugras/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/gems/1.9.1/gems/pg-0.14.1/ext/gem_make.out

I tried setting the pg_config path, my xcode is installed, my command line tools from xcode is installed, my ruby version is 1.9.3 installed by RVM.

My mac is OS X Mountain Lion

Thanks guys!

2

2 Answers

1
votes

You're missing the Postgres client library header files (libpq-fe.h). In Debian the package is called libpq-dev. I don't know Mac packaging at all, but if there's no Mac respository building the PG client libs from source would work.

-1
votes

i would recommend installing rvm https://rvm.io/rvm/install then run rvm requirements. this will install all required packages, you're probably missing "gcc49" after this install rails and yore good to install postgres. i would suggest postgresapp or postgresql.