【问题标题】:Rails and postgres - pg gem ignored during deploy on herokuRails 和 postgres - 在 heroku 上部署期间忽略 pg gem
【发布时间】:2023-04-01 01:58:01
【问题描述】:

我无法在 heroku 上部署我的应用程序。我在 Gemfile 中添加了 'pg' gem,甚至尝试包含 gem 'therubyracer-heroku' 之类的东西。 期间

heroku rake db:migrate

我得到这样的东西:

>heroku rake db:migrate
 --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adap
ter` (pg is not part of the bundle. Add it to Gemfile.)
/app/.bundle/gems/ruby/1.9.1/gems/activerecord-3.1.1/lib/active_record/connectio
n_adapters/abstract/connection_specification.rb:71:in `rescue in establish_conne
ction'

另一个有趣的部分是,在捆绑安装操作期间没有提到推送到 heroku pg,就像它被忽略一样。我还观看了 Gemfile.lock 并在那里提到了 pg:

pg (0.11.0-x86-mingw32)

我想知道是否是 Windows gem 问题导致 heroku 忽略 pg gem 还是什么?

任何人都可以帮助或遇到类似的问题吗?

//编辑

似乎相关:enter link description here

而且看起来无法解决

【问题讨论】:

  • 您最新的 Gemfile 和 Gemfile.lock 是否已在源代码管理中提交?
  • 是的,我这样做是为了改变 gemfile 运行本地包,然后同时提交,然后推送给我错误You have modified your Gemfile in development 所以我在 .lock 文件中更改了某事,比如删除 PLATFORMS 部分以便能够推送
  • OK - 当您的 Gemfile.lock 与 Gemfile 中的内容不一致时,Heroku 通常会发出该消息。我会将您的存储库克隆到一个新位置,然后查看结果只是为了检查它是否在 git 中正确。否则,请联系 Heroku 支持。

标签: ruby-on-rails postgresql heroku


【解决方案1】:

在您的 Gemfile 中将 postgres 限制为您的生产组;

group :production do
  gem "pg"
end

重新打包

bundle --without production

并提交到 git(Gemfile 和 Gemfile.lock)并推送到 Heroku。这应该可以解决您的问题。

【讨论】:

  • ohhh.. 这个限制是必要的吗?没有任何改变,同样的错误:/
  • 我已经完成了所有这些,除了通过 git 将文件推送到 heroku,效果很好,而且我的 rake db:migrate 工作正常!谢谢。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-05-21
  • 1970-01-01
  • 1970-01-01
  • 2015-04-23
  • 1970-01-01
相关资源
最近更新 更多