在Heroku

编程入门 行业动态 更新时间:2024-10-21 09:46:00
本文介绍了在Heroku - Rails中安装gem'pg'的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图在OSX上的rails上安装ruby for heroku ,我为此使用了本教程 。它似乎在终端上安装正常,但在做完之后

$ rails new myapp --database = postgresql cd myapp

我做了这个

rails生成控制器欢迎

出现错误:

在本机上可用的宝石中找不到gem'spring(> = 0)ruby'。 Run bundle install 安装缺失的宝石。

我得到了

'安装pg(0.17.1)时发生错误,并且Bundler无法继续。 确保`gem install pg -v'0.17.1'`在捆绑之前成功。'

然后...

错误:安装pg时出错:错误:无法构建gem原生扩展。 ... 找不到'libpq-fe.h头文件 *** extconf.rb失败*** 无法创建Makefile出于某种原因,可能缺乏必要的库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能需要配置选项。

类似的SO问题表示问题已通过更新XCode解决,但我不认为这是我的问题。如果它还不是很明显,我对终端或红宝石的使用经验不是很了解,所以我不确定该如何解决这个问题。

编辑:

新的错误信息

Gem :: Ext :: BuildError:错误:无法构建gem本机扩展。 /Users/mahireusufzai/.rbenv/versions/2.1.1/bin/ruby extconf.rb 检查pg_config ... yes 使用/ usr / local / bin / pg_config *** extconf.rb失败*** 由于某些原因无法创建Makefile,可能缺少必要的库和/或头文件。检查mkmf.log文件以获取更多详细信息。您可能需要配置选项。

...

/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/2.1.0/mkmf.rb:456:in`try_do':编译器无法生成可执行文件。 (RuntimeError)您必须先安装开发工具。 $ / b / b from /Users/mahireusufzai/版本/ 2.1.1 / lib / ruby​​ / 2.1.0 / mkmf.rb:556:在`try_link'从extconf.rb:39:在`< main>' extconf失败,退出代码1 Gem文件将保持安装在/Users/mahireusufzai/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/pg-0.17。 1进行检查。

解决方案

您需要先安装postgresql开发库。它抱怨缺少libpq-fe.h。

尝试按照以下文章中的答案解决: Rails:安装pg gem时出错

I'm trying to install ruby on rails on OSX for heroku, for which I used this tutorial. It seemed to install fine on the terminal, but after doing

$rails new myapp --database=postgresql cd myapp

I did this

rails generate controller welcome

and got an error:

Could not find gem 'spring (>= 0) ruby' in the gems available on this machine. Runbundle installto install missing gems.

And after following the instructions, I got

'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.'

And then...

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.

A similar SO question said the problem was solved by updating XCode, but I don't think that's my problem. If it wasn't already apparent, I'm not very experienced with the terminal or ruby, so I'm not sure how I can approach this issue.

EDIT:

new error message

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.

解决方案

You need to install the postgresql development libraries first. It's complaining libpq-fe.h is missing.

Try to solve as per the answer in the following post: Rails: Error installing pg gem

更多推荐

在Heroku

本文发布于:2023-10-15 03:00:43,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Heroku

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!