我正在尝试将项目推向heroku ....
我正站在那里说:rails new myapp --database=postgresql
创建命令后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.
在我的MacBook(Mac OS X Mavericks)上,我收到错误:
$ 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
在我的系统上:
答案 0 :(得分:2)
安装Postgres
brew install postgresql
然后你的gem install pg会起作用,它失败了,因为它需要postgresql-client才能工作