简体   繁体   English

Heroku忽略了pg gem

[英]Heroku ignores pg gem

I'm tried to deploy a new version of my app to heroku. 我尝试将新版本的应用程序部署到heroku。 The deployment fails because heroku says, that the gem pg is not in my GEMFILE ... I have this postgres gem in my GEMFILE. 部署失败,因为heroku表示gem pg不在我的GEMFILE中...我的GEMFILE中有此postgres gem。 I also looked for some answers, but no one worked ... As anyone an idea? 我也寻找一些答案,但没人能解决。

I use Ruby 2.0.0p247, Rails 3.2.14 refinery-cms 2.1.0 我使用Ruby 2.0.0p247,Rails 3.2.14finery-cms 2.1.0

Here is my Gemfile: 这是我的Gemfile:

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails'
gem 'newrelic_rpm'

group :production do
  gem 'pg'
  gem 'fog'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails'
  gem 'coffee-rails'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  # gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby'

# To use Jbuilder templates for JSON
 gem 'jbuilder'

# Use unicorn as the app server
 gem 'unicorn'

# Deploy with Capistrano
 gem 'capistrano'

# To use debugger
 gem 'debugger'

# The Heroku gem allows you to interface with Heroku's API
gem 'heroku'

# Fog allows you to use S3 assets (added for Heroku)
gem 'fog'

# Postgres support (added for Heroku)
#gem 'pg'

#Connecting to Amazon S3
gem 'aws-s3'
#gem 'taps'

# Refinery CMS
#gem 'refinerycms', '~> 2.0.0', :git => 'git://github.com/refinery/refinerycms.git', :branch => '2-0-stable'
gem 'refinerycms'

# Specify additional Refinery CMS Extensions here (all optional):
gem 'refinerycms-i18n'
#  gem 'refinerycms-blog', '~> 2.0.0'
#  gem 'refinerycms-inquiries', '~> 2.0.0'
#  gem 'refinerycms-search', '~> 2.0.0'
gem 'refinerycms-page-images'

gem 'refinerycms-announcements', :path => 'vendor/extensions'
gem 'refinerycms-publications', :path => 'vendor/extensions'
gem 'refinerycms-workers', :path => 'vendor/extensions'

And here the error message: 这里是错误消息:

-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/bundler-1.3.2/lib/bundler/rubygems_integration.rb:214:in `block in replace_gem'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/postgresql_adapter.rb:7:in `<top (required)>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:50:in `resolve_hash_connection'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:41:in `resolve_string_connection'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:27:in `spec'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/connection_adapters/abstract/connection_specification.rb:130:in `establish_connection'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:88:in `block (2 levels) in <class:Railtie>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:26:in `block in on_load'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `each'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/lazy_load_hooks.rb:25:in `on_load'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.14/lib/active_record/railtie.rb:80:in `block in <class:Railtie>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:30:in `run'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `each'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:136:in `initialize!'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_37zyls4tcoz59/config/environment.rb:5:in `<top (required)>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.14/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:103:in `require_environment!'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/railties-3.2.14/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /tmp/build_37zyls4tcoz59/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.14/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
       Precompiling assets failed, enabling runtime asset compilation
       Injecting rails31_enable_runtime_asset_compilation
       Please see this article for troubleshooting help:
       http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting

according to the gemfile: 根据gemfile:

# Postgres support (added for Heroku)
#gem 'pg'

pg is commented-out. pg已被注释掉。 uncomment it to install it 取消注释以安装它

gem 'pg'

In my gemfile for instance, I work in windows, and heroku doesn't. 例如,在我的gemfile中,我在Windows中工作,而heroku则不在。 So I have 所以我有

gem "pg", '~> 0.15.1', :group => :production
group :development, :test do
    gem 'pg', "~> 0.15.1", :platform => [:mswin, :mingw]

since you must have some db installed, preferbly pg since it is heroku 因为您必须安装一些数据库,所以最好是pg,因为它是heroku

also, as Gavin in the comments said - make sure you are in production, since it seems that heroku doesn't think o.. 另外,正如加文(Gavin)在评论中所说-确保您已投入生产,因为heroku似乎不认为o ..

The problem is that you have the pg gem in the production group. 问题是您在生产组中拥有pg gem。 Therefore when assets are precompiled on Heroku (which uses the global group + assets group) then the PG gem cannot indeed be found because it's in the production group. 因此,当资产在Heroku(使用全局组+资产组)上进行预编译时,实际上就找不到PG宝石,因为它在生产组中。

I would suggest having the pg gem in the global group and available to allow asset groups. 我建议将pg gem放在全局组中,并允许资产组使用。

Oh no ... the solution was to delete my git repo and create a new one. 哦,不...解决方案是删除我的git repo并创建一个新的。 I don't know why, but my repo got messed up (I added new files and so on ..) and so it didn't commit all data. 我不知道为什么,但是我的仓库搞砸了(我添加了新文件,等等..),所以它没有提交所有数据。 After the tip of chucknelson I tried to lock a certain rails version and saw that heroku didn't get this. 在chucknelson技巧提示之后,我尝试锁定某个Rails版本,并发现heroku没有得到这个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM