推送到Heroku时:应用程序中发生错误,无法提供您的页面。 请稍后重试

我已经被困在这几个小时,似乎无法让它工作。

我正在关注一个教程,我正在尝试将我的应用程序推送到Heroku。

我的gemfile看起来像:

source 'https://rubygems.org' ruby '2.0.0' # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' gem 'rails', '4.1.1' # Gems used only for assets and not required # in production environments by default. group :assets do # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' gem 'coffee-rails' gem 'uglifier', '1.2.3' end # Use jquery as the JavaScript library gem 'jquery-rails' group :development, :test do gem 'sqlite3' gem 'rspec-rails', '2.10.0' end group :production do gem 'pg' end 

当我推到Heroku时,我得到了这个:

  Lisa:sample_app admin-lisa$ git push heroku master Initializing repository, done. Counting objects: 81, done. Delta compression using up to 2 threads. Compressing objects: 100% (68/68), done. Writing objects: 100% (81/81), 17.36 KiB, done. Total 81 (delta 12), reused 0 (delta 0) -----> 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/.......... Fetching additional metadata from https://rubygems.org/.. Installing i18n 0.6.9 Installing rake 10.3.2 Installing minitest 5.3.5 Installing thread_safe 0.3.4 Installing builder 3.2.2 Installing rack 1.5.2 Installing erubis 2.7.0 Installing polyglot 0.3.5 Installing mime-types 1.25.1 Installing coffee-script-source 1.7.0 Installing arel 5.0.1.20140414130214 Installing execjs 2.2.1 Installing hike 1.2.3 Installing thor 0.19.1 Installing multi_json 1.10.1 Using bundler 1.6.3 Installing json 1.8.1 Installing tilt 1.4.1 Installing tzinfo 1.2.1 Installing sass 3.2.19 Installing rack-test 0.6.2 Installing coffee-script 2.2.0 Installing treetop 1.4.15 Installing uglifier 1.2.3 Installing sprockets 2.11.0 Installing activesupport 4.1.1 Installing mail 2.5.4 Installing actionview 4.1.1 Installing activemodel 4.1.1 Installing actionpack 4.1.1 Installing activerecord 4.1.1 Installing actionmailer 4.1.1 Installing sprockets-rails 2.1.3 Installing railties 4.1.1 Installing jquery-rails 3.1.1 Installing coffee-rails 4.0.1 Installing sass-rails 4.0.3 Installing rails 4.1.1 Installing pg 0.17.1 Your bundle is complete! Gems in the groups development and test were not installed. It was installed into ./vendor/bundle Bundle completed (27.18s) Cleaning up the bundler cache. -----> Preparing app for Rails asset pipeline Running: rake assets:precompile rake aborted! Sprockets::FileNotFound: couldn't find file 'turbolinks' (in /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/app/assets/javascripts/application.js:15) /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:106:in `resolve' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:146:in `require_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:217:in `process_require_directive' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:167:in `block in process_directives' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `each' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:165:in `process_directives' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/directive_processor.rb:99:in `evaluate' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:197:in `block in evaluate' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `each' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/context.rb:194:in `evaluate' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/processed_asset.rb:12:in `initialize' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `new' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:374:in `block in build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:395:in `circular_call_protection' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:373:in `build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/bundled_asset.rb:16:in `initialize' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `new' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:377:in `build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:94:in `block in build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/caching.rb:58:in `cache_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:93:in `build_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/base.rb:287:in `find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/index.rb:61:in `find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:211:in `block in find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:257:in `benchmark' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:210:in `find_asset' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:119:in `block in compile' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `each' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/sprockets/manifest.rb:118:in `compile' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:61:in `block (3 levels) in define' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-2.11.0/lib/rake/sprocketstask.rb:146:in `with_logger' /tmp/build_868a3914-b83c-496d-b715-75262204c9cf/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.1.3/lib/sprockets/rails/task.rb:60:in `block (2 levels) in define' Tasks: TOP => assets:precompile (See full trace by running task with --trace) ! ! Precompiling assets failed. ! ! Push rejected, failed to compile Ruby app To git@heroku.com:polar-wave-2691.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'git@heroku.com:polar-wave-2691.git' 

当我访问Heroku网站时,它说:应用程序错误应用程序中发生错误,无法提供您的页面。 请稍后重试。

如果您是应用程序所有者,请检查日志以获取详细信息。

所以我检查了我的日志,其中说:

 Lisa:sample_app admin-lisa$ heroku logs 2014-06-27T00:07:21.685434+00:00 heroku[api]: Enable Logplex by somebody.lisa@gmail.com 2014-06-27T00:07:21.685490+00:00 heroku[api]: Release v2 created by somebody.lisa@gmail.com 2014-06-27T00:07:29+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:07:33+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:07:40.377399+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=5b29dca1-29e3-4410-8efb-99c74f1b14ec fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:07:40.673553+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=39df86cb-8d9c-418f-afb9-8242fc5f311e fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:03.130094+00:00 heroku[api]: Starting process with command `rake db:migrate` by somebody.lisa@gmail.com 2014-06-27T00:08:04.869272+00:00 heroku[run.1405]: State changed from starting to up 2014-06-27T00:08:06.629224+00:00 heroku[run.1405]: State changed from up to complete 2014-06-27T00:08:04.809756+00:00 heroku[run.1405]: Starting process with command `rake db:migrate` 2014-06-27T00:08:06.612075+00:00 heroku[run.1405]: Process exited with status 1 2014-06-27T00:08:04.774227+00:00 heroku[run.1405]: Awaiting client 2014-06-27T00:08:10.068439+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=a6c649ff-2b4b-4a67-9bfa-c2e06b623c8a fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:10.354925+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=60a03227-4cfa-4ba3-b2e5-f84b63b0db07 fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:13.488700+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=21eb1930-2b7e-4e57-b0df-3fffaeffae29 fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:13.851121+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=9b015c1f-e710-4866-acba-0f215ea5938d fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:40.685450+00:00 heroku[run.2450]: Awaiting client 2014-06-27T00:08:40.746839+00:00 heroku[run.2450]: Starting process with command `rake db:migrate` 2014-06-27T00:08:39.220494+00:00 heroku[api]: Starting process with command `rake db:migrate` by jonsson.lisa@gmail.com 2014-06-27T00:08:40.730443+00:00 heroku[run.2450]: State changed from starting to up 2014-06-27T00:08:42.454908+00:00 heroku[run.2450]: State changed from up to complete 2014-06-27T00:08:42.363758+00:00 heroku[run.2450]: Process exited with status 1 2014-06-27T00:08:55.126228 +00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=5f1ec80d-7dc1-4810-91a1-1f61b7f1dc66 fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:08:55.685930+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=03a9fa47-7148-4a12-b7ec-ffe2100f4161 fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:16:47.224352+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/" host=polar-wave-2691.herokuapp.com request_id=fccc625d-9bd2-4d2b-8d95-a51fe4d210eb fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:16:47.589404+00:00 heroku[router]: at=error code=H14 desc="No web processes running" method=GET path="/favicon.ico" host=polar-wave-2691.herokuapp.com request_id=336a9fd4-47c7-4342-a7c2-3815eb0b84d3 fwd="50.143.161.142" dyno= connect= service= status=503 bytes= 2014-06-27T00:17:01+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:17:05+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:18:13+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:19:08+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:20:16+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:21:03+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:22:11+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:22:39+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:23:31+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:23:56+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:24:37+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:25:06+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:26:09+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:26:37+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 2014-06-27T00:39:14+00:00 heroku[slug-compiler]: Slug compilation started 2014-06-27T00:39:51+00:00 heroku[slug-compiler]: Slug compilation failed: failed to compile Ruby app 

我完全不明白它试图告诉我什么,但我试图跑

 rake assets:precompile 

 heroku run rake db:migrate 

我还检查了我的git状态,一切都已经提交。

我尝试删除我的gemfile.lock并再次运行bundle并rake db:migrate并将其全部提交,但没有运气。

我只是在学习Rails,而heroku日志对我来说并不完全有意义。

谢谢。

你的application.js文件是什么样的? 如果你正在使用turbolinks摆脱它。 Rails可能正在尝试为您预编译您的资产并将其缩小,但这可能会让您失望。 另请查看https://github.com/heroku/rails_12factor ,您可能需要安装此gem。

几个星期前,当我构建我的第一个rails应用程序时,我遇到了类似的问题。 我会继续删除你的sass-rails gem,以及组资产,重新捆绑,再给它一个镜头。

应该是这样的:

 gem 'coffee-rails' gem 'uglifier', '1.2.3' 

 group :assets do # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' gem 'coffee-rails' gem 'uglifier', '1.2.3' end 

在你的gemfile中尝试将gem’trail_12factor’添加到生产中。 所以代码应该改变

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

 ... group :production do gem 'pg' gem 'rails_12factor' end 

编辑:这是我的整个Gemfile

 source 'https://rubygems.org' gem 'rails', '4.1.1' # Use sqlite3 as the database for Active Record # gem 'sqlite3' # Use SCSS for stylesheets gem 'sass-rails', '~> 4.0.3' # Use Uglifier as compressor for JavaScript assets gem 'uglifier', '>= 1.3.0' # Use CoffeeScript for .js.coffee assets and views gem 'coffee-rails', '~> 4.0.0' # See https://github.com/sstephenson/execjs#readme for more supported runtimes # gem 'therubyracer', platforms: :ruby # Use jquery as the JavaScript library gem 'jquery-rails' # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks gem 'turbolinks' # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder gem 'jbuilder', '~> 2.0' # bundle exec rake doc:rails generates the API under doc/api. gem 'sdoc', '~> 0.4.0', group: :doc # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring gem 'spring', group: :development # Deploying to Heroku group :production do gem 'pg' gem 'rails_12factor' end group :development, :test do gem 'sqlite3' end 

以下是为我解决的一些问题(感谢@plondon,这是一个很好的眼睛!)

因为我从我的Gemfile中取出了turbolinks,所以我还必须确保我的application.css / .js没有使用它。 我清理了两个文件。

我还删除了我的Gemlock.file并再次安装了bundle。

最后,在强制推送之后,它经历了,特别是因为我的application.js在我没有安装时使用Turbolinks。

您可以按照以下步骤操作:

  1. 从Gemfile中删除gem’turbolinks gem 'turbolinks'行。
  2. 从app / assets / javascripts / application.js中删除//= require turbolinks
  3. 从app / views / layouts / application.html.erb中删除两个"data-turbolinks-track" => true哈希键/值对

在你的Gemfile中

 gem "foreman" group :production, :staging do gem "rails_12factor" gem "rails_stdout_logging" gem "rails_serve_static_assets" end 

更多细节删除turbolink