在Heroku – Rails中安装gem’pg’的问题
我正在尝试在OSX上的rails上安装ruby for heroku ,为此我使用了本教程 。 它似乎在终端上安装得很好,但在做完之后
$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
bundle install 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解决了问题,但我不认为这是我的问题。 如果还不是很明显,我对终端或ruby不是很有经验,所以我不确定如何解决这个问题。
编辑:
新的错误消息
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 `' 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丢失了。
尝试按照以下post中的答案解决: Rails:安装pg gem时出错
尝试
yum install postgresql-devel
要么
brew install postgresql
那么gem install pg
应该可行
- OmniAuth Strategies Facebook NoAuthorizationCodeError(必须传递`code`参数或签名请求(通过`signed_request`参数):
- 从localhost发送电子邮件
- Sinatra + Heroku + Datamapper使用dm-sqlite-adapter部署问题
- Heroku记录FATAL SignalException:SIGTERM
- 我如何设置heroku postgresql应用程序的路径?
- Heroku app坚持使用HTTPS – 为什么?
- phusion乘客是否使用分叉,如果是,在哪里设置after_fork配置?
- 相关模型的每个实例的活动管理范围
- 你如何在heroku中运行“Rails Runner”?
- Heroku | Ruby ArgumentError:缺少必需的参数:
- 如何让Heroku识别子目录(而不是root)中的yarn.lock或package.json