ciaodarwin
ciaodarwin

Reputation: 481

RoR - Failed to installing pg on rails app

I'm trying to push a project to heroku....

I'm at the step where it say's: rails new myapp --database=postgresql

After I created the command: rails new heroku:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /usr/local/rvm/rubies/ruby-2.0.0-rc2/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... *** 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=/usr/local/rvm/rubies/ruby-2.0.0-rc2/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}/
/usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:562:in `try_cpp'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:1086:in `block in find_header'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:892:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:307:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:307:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:1085:in `find_header'
    from extconf.rb:48:in `<main>'


Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-rc2@gemset/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-rc2@gemset/gems/pg-0.17.0/ext/gem_make.out

An error occurred while installing pg (0.17.0), and Bundler cannot continue.
Make sure that `gem install pg -v '0.17.0'` succeeds before bundling.

On my MacBook(Mac OS X Mavericks) I get the error:

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

        /usr/local/rvm/rubies/ruby-2.0.0-rc2/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... *** 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=/usr/local/rvm/rubies/ruby-2.0.0-rc2/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}/
/usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:431:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:562:in `try_cpp'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:1086:in `block in find_header'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:892:in `block in checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:337:in `block (2 levels) in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:307:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:337:in `block in postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:307:in `open'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:333:in `postpone'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:891:in `checking_for'
    from /usr/local/rvm/rubies/ruby-2.0.0-rc2/lib/ruby/2.0.0/mkmf.rb:1085:in `find_header'
    from extconf.rb:48:in `<main>'


Gem files will remain installed in /usr/local/rvm/gems/ruby-2.0.0-rc2@gemset/gems/pg-0.17.0 for inspection.
Results logged to /usr/local/rvm/gems/ruby-2.0.0-rc2@gemset/gems/pg-0.17.0/ext/gem_make.out

On my system:

Upvotes: 2

Views: 120

Answers (1)

bjhaid
bjhaid

Reputation: 9782

Install Postgres

brew install postgresql

Then your gem install pg would work, it is failing because it needs the postgresql-client to work

Upvotes: 2

Related Questions