2013-08-16 117 views
0

我試圖將我的應用的新版本部署到heroku。部署失敗,因爲heroku說,gem pg不在我的GEMFILE中......我在我的GEMFILE中有這個postgres gem。我也尋找一些答案,但沒有人工作......任何人都有想法?Heroku忽略pg gem

我使用Ruby 2.0.0p247,Rails的3.2.14煉油廠CMS 2.1.0

這裏是我的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' 

而且這裏的錯誤消息:

-----> 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 
+0

您是否將'RAILS_ENV'設置爲heroku以外的產品?我也嘗試從生產組中拉出gem命令。 –

+0

您還需要執行'gem install activerecord-postgresql-adapter',或將其添加到您的Gemfile中。 – vee

+0

它仍然不起作用。我在我的environment.rb中添加了ENV ['RAILS_ENV'] || ='production'。我還添加了gem activerecord-postgresql-adapter,並且我也刪除了資產和生產標籤。 – gadreel

回答

-1

噢不...解決方案是刪除我的git回購並創建一個新的。我不知道爲什麼,但我的回購混亂了(我添加了新的文件等),所以它沒有提交所有數據。在chucknelson的尖端之後,我試圖鎖定某個rails版本,並發現heroku沒有得到這個。

+0

這不應該是「接受的答案」 –

2

根據gemfile:

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

pg已被註釋掉。取消它的註釋來安裝它

gem 'pg' 

在我的gemfile例如,我在Windows上工作,而且heroku沒有。所以,我有

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

,因爲你必須安裝一些分貝,preferbly皮克因爲它的Heroku

也作爲加文在評論中說 - 確保你是在生產,因爲它似乎的Heroku沒有按沒想到O ..

+0

完成此操作後,您可以安全地從「生產」組中刪除。 –

+0

我想我也試過這個。我會再次測試它。在例子中,我也在生產標籤和標籤之外。 – gadreel

+0

它沒有工作。我沒有捆綁安裝。 git commit。 heroku推大師 – gadreel

0

問題是你在生產組中有PG的寶石。因此,當資產在Heroku上預編譯(使用全局組+資產組)時,PG寶石確實無法找到,因爲它位於生產組中。

我會建議在全局組中擁有pg gem並且可以允許資產組。

+0

正如我已經提到,我也試過這個。它仍然無法正常工作。 – gadreel