[英]Issue with the installation of gem 'pg' in Heroku - Rails
我正在尝试在heroku的 OSX的Rails上安装ruby,为此我使用了本教程 。 它似乎在终端上安装正常,但是在完成之后
$rails new myapp --database=postgresql
cd myapp
我做了这个
rails generate controller welcome
并得到一个错误:
Could not find gem 'spring (>= 0) ruby' in the gems available on this machine. Run
Could not find gem 'spring (>= 0) ruby' in the gems available on this machine. Run
捆绑安装to install missing gems.
按照指示操作后,我得到了
'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.'
接着...
ERROR: Error installing pg:
ERROR: Failed to build gem native extension.
...
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.
一个类似的SO问题说,通过更新XCode解决了该问题,但是我不认为这是我的问题。 如果还不很明显,那么我对终端或红宝石的经验还不是很丰富,所以我不确定如何解决这个问题。
编辑:
新的错误信息
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/Users/mahireusufzai/.rbenv/versions/2.1.1/bin/ruby extconf.rb
checking for pg_config... yes
Using config values from /usr/local/bin/pg_config
*** 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.
...
/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:541:in `try_link0'
from /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:556:in `try_link'
from extconf.rb:39:in `<main>'
extconf failed, exit code 1
Gem files will remain installed in /Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/pg-0.17.1 for inspection.
您需要先安装postgresql开发库。 它抱怨libpq-fe.h丢失。
尝试按照以下帖子中的答案解决: Rails:安装pg gem时出错
尝试
yum install postgresql-devel
要么
brew install postgresql
然后gem install pg
应该工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.