Heroku 应用程序缺少 postgresql 适配器,无法使用 Rails 3.1.3 进行 Rake db:migrate

发布于 2025-01-05 11:10:40 字数 1401 浏览 0 评论 0原文

我有一个 Rails 应用程序,我想在 heroku 上运行来测试。我使用的是 Rails 3.1.3,我无法在 Heroku 上获取该应用程序的数据库。不过,推送应用程序效果很好。当我尝试 heroku rake db:migrate 时,出现错误:

耙子中止! 请安装 postgresql 适配器:gem install activerecord-postgresql-adapter (pg 不是捆绑包的一部分。添加它 到 Gemfile。)

我尝试将 gem 'pg' 添加到 Gemfile 中。然后,当我将应用程序推送到 heroku 时,出现错误:

您已添加到 Gemfile: * 页面 失败:http://devcenter.heroku.com/articles/bundler ! Heroku推送被拒绝,无法通过Bundler安装gems

我不明白为什么它不会安装,所以我尝试在本地安装它以查看是否存在问题,并且它也不会在本地安装。我使用 RVM,当尝试捆绑安装时,我得到

Gem::Installer::ExtensionBuildError: 错误: 无法构建 gem 本机 扩展名。

 /Users/username/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb 检查 pg_config... 否 没有 pg_config... 尝试
无论如何。如果构建失败,请重试 --with-pg-config=/path/to/pg_config 检查 libpq-fe.h... 否 找不到 'libpq-fe.h 标头 * extconf.rb 失败 * 由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件。查看 有关更多详细信息,请参阅 mkmf.log 文件。您可能需要配置 选项。

** 更多不重要的行 **

em 文件将保留安装在 /Users/用户名/.rvm/gems/ruby-1.9.2-p180@nebular2/gems/pg-0.13.1 供检查。结果记录到 /Users/用户名/.rvm/gems/ruby-1.9.2-p180@nebular2/gems/pg-0.13.1/ext/gem_make.out 安装pg(0.13.1)时出错,Bundler无法 继续。确保 gem install pg -v '0.13.1' 成功 捆绑。

有人明白发生了什么事吗?我似乎不知道如何修复这个错误。

I have a rails app I want to run on heroku to test. I am using rails 3.1.3, and I can't get the app the rake the database on heroku. Pushing the app works fine though. When I try heroku rake db:migrate I get the error:

rake aborted!
Please install the postgresql adapter: gem install activerecord-postgresql-adapter (pg is not part of the bundle. Add it
to Gemfile.)

I tried adding gem 'pg' to the Gemfile. Then when I push the app to heroku I get the error:

You have added to the Gemfile:
* pg
FAILED: http://devcenter.heroku.com/articles/bundler
! Heroku push rejected, failed to install gems via Bundler

I don't get why it won't install, so I tried to install it locally to see if there was an issue there, and it won't install locally either. I use RVM, and when trying to bundle install I get

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

    /Users/username/.rvm/rubies/ruby-1.9.2-p180/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... no 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.

** more lines that are unimportant **

em files will remain installed in
/Users/username/.rvm/gems/ruby-1.9.2-p180@nebular2/gems/pg-0.13.1
for inspection. Results logged to
/Users/username/.rvm/gems/ruby-1.9.2-p180@nebular2/gems/pg-0.13.1/ext/gem_make.out
An error occured while installing pg (0.13.1), and Bundler cannot
continue. Make sure that gem install pg -v '0.13.1' succeeds before
bundling.

Anyone understand what is going on? I cannot seem to figure out how to fix this error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

南笙 2025-01-12 11:10:40

您需要安装 PostgreSQL http://www.postgresql.org/download/macosx/

然后您需要重置一些路径(在终端中):

 $ PATH=/Library/PostgreSQL/9.1/bin:$PATH

然后只需捆绑安装。

You need to install PostgreSQL http://www.postgresql.org/download/macosx/

Then you need to reset some paths (in Terminal):

 $ PATH=/Library/PostgreSQL/9.1/bin:$PATH

Then just bundle install.

暮凉 2025-01-12 11:10:40

您没有所需的标头。您必须先在系统上安装 libpq dev 或 devel(开发工具取决于您的系统),然后重试 bundle install

例如,fedora 的软件包是 libpqxx-devel 。

You haven't the required headers. You have to install libpq dev or devel (development tools depending on your system) on your system first and then retry bundle install

For exemple, the package for fedora is libpqxx-devel.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文