heroku rails 应用程序构建失败

heroku rails application build failure

-----> Removing .DS_Store files
-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
       Fetching gem metadata from https://rubygems.org/...........
       Installing multi_json 1.10.1
       Installing i18n 0.7.0
       Installing rake 10.4.2
       Installing builder 3.0.4
       Installing journey 1.0.4
       Installing erubis 2.7.0
       Installing hike 1.2.3
       Installing rack 1.4.5
       Installing tilt 1.4.1
       Installing polyglot 0.3.5
       Installing mime-types 1.25.1
       Installing arel 3.0.3
       Installing bootstrap-sass 2.0.0
       Installing tzinfo 0.3.42
       Installing coffee-script-source 1.8.0
       Installing execjs 2.2.2
       Installing thor 0.19.1
       Installing bcrypt-ruby 3.0.1
       Using bundler 1.6.3
       Installing sass 3.4.9
       Installing json 1.8.1
       Installing rack-cache 1.2
       Installing activesupport 3.2.21
       Installing rack-test 0.6.2
       Installing rack-ssl 1.3.4
       Installing sprockets 2.2.3
       Installing treetop 1.4.15
       Installing coffee-script 2.3.0
       Installing uglifier 1.2.3
       Installing activemodel 3.2.21
       Installing rdoc 3.12.2
       Installing mail 2.5.4
       Installing actionpack 3.2.21
       Installing activerecord 3.2.21
       Installing activeresource 3.2.21
       Installing actionmailer 3.2.21
       Installing railties 3.2.21
       Installing pg 0.12.2
       Installing coffee-rails 3.2.2
       Installing jquery-rails 2.0.1
       Installing rails 3.2.21
       Installing sass-rails 3.2.4
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Post-install message from rdoc:
       Depending on your version of ruby, you may need to install ruby rdoc/ri data:
       <= 1.8.6 : unsupported
       = 1.8.7 : gem install rdoc-data; rdoc-data --install
       = 1.9.1 : gem install rdoc-data; rdoc-data --install
       >= 1.9.2 : nothing to do! Yay!
       Bundle completed (17.28s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_88f0e85760141090706776361438977e/Rakefile:7)
       DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! Support for these plugins will be removed in Rails 4.0. Move them out and bundle them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/initializers/myplugin.rb. See the release notes for more on this: http://weblog.rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from <top (required)> at /tmp/build_88f0e85760141090706776361438977e/Rakefile:7)
       rake aborted!
       PGError: could not connect to server: Connection refused
       Is the server running on host "127.0.0.1" and accepting
       TCP/IP connections on port 5432?
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `initialize'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `new'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:1222:in `connect'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:324:in `initialize'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/model_schema.rb:310:in `clear_cache!'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activerecord-3.2.21/lib/active_record/railtie.rb:103:in `block (2 levels) in <class:Railtie>'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:418:in `_run__971333411375098380__prepare__1628314258144706216__callbacks'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:405:in `__run_callback'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/callbacks.rb:81:in `run_callbacks'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:30:in `run'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `each'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:136:in `initialize!'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_88f0e85760141090706776361438977e/config/environment.rb:5:in `<top (required)>'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/activesupport-3.2.21/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:103:in `require_environment!'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/railties-3.2.21/lib/rails/application.rb:305:in `block (2 levels) in initialize_tasks'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /tmp/build_88f0e85760141090706776361438977e/vendor/bundle/ruby/2.0.0/gems/actionpack-3.2.21/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.
 !     Attempted to access a nonexistent database:
 !     https://devcenter.heroku.com/articles/pre-provision-database
 !

 !     Push rejected, failed to compile Ruby app

gemfile

source 'https://rubygems.org'

gem 'rails', '~> 3.2.3'
gem 'bootstrap-sass', '2.0.0'
gem 'bcrypt-ruby', '3.0.1'
# gem 'pg', '0.12.2' #seems to not work try below
gem 'pg', '0.12.2'
gem 'pry-remote'

# Bundle edge Rails instead:key => "value",
# gem 'rails', :git => 'git://github.com/rails/rails.git'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.10.0'
  gem 'guard-rspec', '0.5.5'
  gem 'annotate', '~> 2.4.1.beta'
  gem 'factory_girl_rails', '1.4.0'
end

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

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

  gem 'uglifier', '1.2.3'
end

gem 'jquery-rails', '2.0.1'

# Test gems on Macintosh OS X 
group :test do
  gem 'capybara', '1.1.2'
  gem 'growl', '1.0.3'

  gem 'guard-spork', '0.3.2'
  gem 'spork', '0.9.0'
  gem 'factory_girl_rails', '1.4.0'
end

您似乎还没有设置生产数据库,并且正确配置了您的应用程序来为生产数据库查找相应的 ENV 变量(特别是 ENV['DATABASE_URL'] 变量)。

有关 Rails 中此设置的详细信息,请参阅文档的 Heroku Postgres docs for all the setup details, Ruby section

根据您的日志,您的数据库存在问题。默认情况下,heroku 支持 PG,但您可以使用 mysql 或其他数据库。如果您想使用 PG,请将 pg gem 添加到您的 gem 文件中。喜欢:

gem 'pg' 

仅供参考,与 database.yml 和 heroku 没有任何关系 ;) 但是您需要添加 postgree 插件来启动和运行您的应用程序。关注:Postgre

希望您现在对 DB 和 Heroku 有了全面的了解。