Rails 4: 推送被拒绝,编译失败 Ruby app

Rails 4: Push rejected, failed to compile Ruby app

我正在研究 Rails 4.

作为 Michael Hartl 的 Rails 教程中推荐的最佳实践,我尝试尽早并经常进行部署,以避免在开发过程中出现复杂的问题。

一切正常,直到最近:我 运行ning git push heroku master 并且该应用程序在本地和 Heroku 上以相同的方式工作。

但是,现在,当我尝试将我的代码推送到 Heroku 时,出现以下错误:

Counting objects: 26, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (25/25), done.
Writing objects: 100% (26/26), 3.07 KiB | 0 bytes/s, done.
Total 26 (delta 14), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Ruby app detected
remote: -----> Compiling Ruby/Rails
remote: -----> Using Ruby version: ruby-2.0.0
remote: -----> Installing dependencies using 1.9.7
remote:        Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4 --deployment
remote:        Rubygems 2.0.14 is not threadsafe, so your gems must be installed one at a time. Upgrade to Rubygems 2.1.0 or higher to enable parallel gem installation.
remote:        Using rake 10.4.2
remote:        Using i18n 0.7.0
remote:        Using json 1.8.3
remote:        Using minitest 5.8.0
remote:        Using thread_safe 0.3.5
remote:        Using tzinfo 1.2.2
remote:        Using activesupport 4.2.2
remote:        Using builder 3.2.2
remote:        Using erubis 2.7.0
remote:        Using mini_portile 0.6.2
remote:        Using nokogiri 1.6.6.2
remote:        Using rails-deprecated_sanitizer 1.0.3
remote:        Using rails-dom-testing 1.0.7
remote:        Using loofah 2.0.3
remote:        Using rails-html-sanitizer 1.0.2
remote:        Using actionview 4.2.2
remote:        Using rack 1.6.4
remote:        Using rack-test 0.6.3
remote:        Using actionpack 4.2.2
remote:        Using globalid 0.3.6
remote:        Using activejob 4.2.2
remote:        Using mime-types 2.6.1
remote:        Using mail 2.6.3
remote:        Using actionmailer 4.2.2
remote:        Using activemodel 4.2.2
remote:        Using arel 6.0.3
remote:        Using activerecord 4.2.2
remote:        Using execjs 2.6.0
remote:        Using autoprefixer-rails 5.2.1.2
remote:        Using bcrypt 3.1.10
remote:        Using sass 3.4.18
remote:        Using bootstrap-sass 3.3.5.1
remote:        Using coffee-script-source 1.9.1.1
remote:        Using coffee-script 2.4.1
remote:        Using thor 0.19.1
remote:        Using railties 4.2.2
remote:        Using coffee-rails 4.1.0
remote:        Using orm_adapter 0.5.0
remote:        Using responders 2.1.0
remote:        Using warden 1.2.3
remote:        Using devise 3.5.2
remote:        Using multi_json 1.11.2
remote:        Using jbuilder 2.3.1
remote:        Using jquery-rails 4.0.4
remote:        Using turbolinks 2.5.3
remote:        Using jquery-turbolinks 2.1.0
remote:        Using pg 0.18.2
remote:        Using puma 2.13.4
remote:        Using bundler 1.9.7
remote:        Using sprockets 3.3.3
remote:        Using sprockets-rails 2.3.2
remote:        Using rails 4.2.2
remote:        Using rails_serve_static_assets 0.0.4
remote:        Using rails_stdout_logging 0.0.4
remote:        Using rails_12factor 0.0.3
remote:        Using rdoc 4.2.0
remote:        Using tilt 1.4.1
remote:        Using sass-rails 5.0.3
remote:        Using sdoc 0.4.1
remote:        Using uglifier 2.7.1
remote:        Bundle complete! 22 Gemfile dependencies, 60 gems now installed.
remote:        Gems in the groups development and test were not installed.
remote:        Bundled gems are installed into ./vendor/bundle.
remote:        Bundle completed (0.56s)
remote:        Cleaning up the bundler cache.
remote: -----> Preparing app for Rails asset pipeline
remote:        Running: rake assets:precompile
remote:        rake aborted!
remote:        SyntaxError: /tmp/build_c8c1797d62ce933566e19803262e7a1d/config/environments/production.rb:95: syntax error, unexpected keyword_end, expecting '}'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/engine.rb:598:in `block (2 levels) in <class:Engine>'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/engine.rb:597:in `each'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/engine.rb:597:in `block in <class:Engine>'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `instance_exec'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:30:in `run'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:55:in `block in run_initializers'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:44:in `each'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:44:in `tsort_each_child'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/initializable.rb:54:in `run_initializers'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:352:in `initialize!'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/config/environment.rb:5:in `<top (required)>'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `block in require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:240:in `load_dependency'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/activesupport-4.2.2/lib/active_support/dependencies.rb:274:in `require'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:328:in `require_environment!'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/railties-4.2.2/lib/rails/application.rb:457:in `block in run_tasks_blocks'
remote:        /tmp/build_c8c1797d62ce933566e19803262e7a1d/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.3.2/lib/sprockets/rails/task.rb:64:in `block (2 levels) in define'
remote:        Tasks: TOP => environment
remote:        (See full trace by running task with --trace)
remote:  !
remote:  !     Precompiling assets failed.
remote:  !
remote: 
remote:  !     Push rejected, failed to compile Ruby app
remote: 
remote: Verifying deploy....
remote: 
remote: !   Push rejected to calendy.
remote: 
To https://git.heroku.com/calendy.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/calendy.git'

我不太确定,但我相信这个错误是在我 运行 heroku run rake db:reset 之后开始发生的,因为我想重置我的 Heroku 数据库。

以下是我在发布此问题之前尝试过的解决方案:

以上的

None 有效。

这里有两件事我似乎无法理解:

  1. 出了什么问题,我该如何解决?

  2. 为什么事情一开始就停止工作了?

好的,我刚刚理解错了。

我的 production.rb 文件中存在语法错误,如我在问题中分享的终端代码中所述:

remote:        SyntaxError: /tmp/build_c8c1797d62ce933566e19803262e7a1d/config/environments/production.rb:95: syntax error, unexpected keyword_end, expecting '}'

我只需要:

  • 修复 production.rb 文件中的这个语法错误——即将缺少的 } 添加到我的代码中
  • 运行 git add .
  • 运行 git commit -m "Fix production.rb syntax error"
  • 运行 git push origin master

然后 git push heroku master 又开始工作了。