在将应用程序部署到heroku时预编译资产问题

时间:2014-02-15 12:23:49

标签: ruby-on-rails ruby heroku

我无法将Ruby on Rails应用程序部署到heroku,我得到了Precompiling assets failed !。它在我的localhost中正常工作。我无法弄清楚导致这个问题的原因。还在application.rb中添加了config.assets.initialize_on_precompile = false,但没有帮助。 :(

这是日志

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.5.2
       New app detected loading default bundler cache
       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/..
       Using minitest (4.7.5)
       Using atomic (1.1.14)
       Using tzinfo (0.3.38)
       Using builder (3.1.4)
       Using erubis (2.7.0)
       Using rack (1.5.2)
       Installing multi_json (1.8.4)
       Using polyglot (0.3.3)
       Using activerecord-deprecated_finders (1.0.3)
       Installing mime-types (1.25.1)
       Installing i18n (0.6.9)
       Using bcrypt-ruby (3.1.2)
       Using sass (3.2.10)
       Using thor (0.18.1)
       Installing rake (10.1.1)
       Installing ambry (0.3.1)
       Installing highline (1.6.19)
       Installing arel (4.0.2)
       Installing fssm (0.2.10)
       Installing net-ssh (2.7.0)
       Installing dalli (2.6.4)
       Using execjs (2.0.1)
       Installing orm_adapter (0.4.0)
       Using bundler (1.5.2)
       Using hike (1.2.3)
       Using tilt (1.4.1)
       Installing chunky_png (1.2.9)
       Installing differ (0.1.2)
       Installing httpauth (0.2.0)
       Installing multipart-post (1.2.0)
       Installing hashie (2.0.5)
       Installing redis (3.0.4)
       Installing oauth (0.4.7)
       Installing rack-google-analytics (0.12.0)
       Using rails_serve_static_assets (0.0.1)
       Using rails_stdout_logging (0.0.3)
       Installing newrelic_rpm (3.6.7.152)
       Installing ref (1.0.5)
       Using thread_safe (0.1.3)
       Using rack-test (0.6.2)
       Installing warden (1.2.3)
       Installing jwt (0.1.8)
       Using treetop (1.4.15)
       Installing libv8 (3.16.14.3)
       Installing bourbon (3.1.8)
       Installing merit (1.6.1)
       Installing similar_text (0.0.4)
       Installing net-scp (1.1.2)
       Using uglifier (2.2.1)
       Installing net-sftp (2.1.2)
       Installing net-ssh-gateway (1.2.0)
       Installing sprockets (2.10.1)
       Installing omniauth (1.1.4)
       Installing faraday (0.8.8)
       Using rails_12factor (0.0.2)
       Installing leaderboard (3.3.0)
       Using mail (2.5.4)
       Installing compass (0.12.2)
       Installing activesupport (4.0.2)
       Installing omniauth-oauth (1.0.1)
       Installing capistrano (2.15.5)
       Installing compass-flexbox (1.1.3)
       Installing oauth2 (0.8.1)
       Installing compass-rails (1.1.3)
       Installing activemodel (4.0.2)
       Installing actionpack (4.0.2)
       Installing omniauth-twitter (1.0.0)
       Installing omniauth-oauth2 (1.1.1)
       Installing rvm-capistrano (1.5.0)
       Installing actionmailer (4.0.2)
       Installing activerecord (4.0.2)
       Using sprockets-rails (2.0.1)
       Installing omniauth-facebook (1.4.1)
       Installing mysql2 (0.3.14)
       Installing railties (4.0.2)
       Using jquery-rails (3.0.4)
       Installing sass-rails (4.0.0)
       Installing devise (3.1.0)
       Installing rails (4.0.2)
       Installing figaro (0.7.0)
       Installing therubyracer (0.12.0)
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Post-install message from newrelic_rpm:
       # New Relic Ruby Agent Release Notes #
       ## v3.6.7 ##
       * Resque-pool support
       Resque processes started via the resque-pool gem weren't recognized by the
       Ruby agent. The agent now starts correctly in those worker processes.
       * Environment-based configuration
       All settings in newrelic.yml can now be configured via environment variables.
       See https://newrelic.com/docs/ruby/ruby-agent-configuration for full details.
       * Fix compatibility issues with excon and curb instrumentation
       This release of the agent fixes a warning seen under certain circumstances
       with the excon gem (most notably, when excon was used by fog), as well as
       a bug with the curb instrumentation that conflicted with the  feedzirra gem.
       * Allow license key to be set by Capistrano variables
       A license key can be passed via a Capistrano variable where previously it
       could only be in newrelic.yml. Thanks Chris Marshall for the contribution!
       * Make HTTP client instrumentation aware of "Host" request header
       If a "Host" header is set explicitly on an HTTP request, that hostname will
       be used for external metrics. Thanks Mislav Marohnić for the contribution!
       * Fix ActiveSupport::Concern warnings with MethodTracer
       Including NewRelic::Agent::MethodTracer in a class using Concerns could cause
       deprecation warnings. Thanks Mike Połtyn for the contribution!
       * Fix Authlogic constant name
       Code checking for the Authlogic module was using in the wrong case. Thanks
       Dharam Gollapudi for the contribution!
       See https://github.com/newrelic/rpm/blob/master/CHANGELOG for a full list of
       changes.
       Bundle completed (84.27s)
       Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       undefined method `split' for nil:NilClass
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/config/environments/production.rb:59:in `block in <top (required)>'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:24:in `class_eval'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:24:in `configure'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/config/environments/production.rb:1:in `<top (required)>'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:590:in `each'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/engine.rb:590:in `block in <class:Engine>'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:30:in `run'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `each'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:44:in `tsort_each_child'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:215:in `initialize!'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/config/environment.rb:5:in `<top (required)>'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `block in require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:214:in `load_dependency'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.2/lib/active_support/dependencies.rb:229:in `require'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:189:in `require_environment!'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/application.rb:250:in `block in run_tasks_blocks'
       /tmp/build_c4ee6d25-fbcb-4b04-85c5-5f602f951339/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
       Tasks: TOP => environment
       (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby app

任何帮助和建议都非常值得赞赏。感谢

2 个答案:

答案 0 :(得分:1)

这是问题所在:

undefined method `split' for nil:NilClass

它看起来像59的{​​{1}}一样 - 您是否在应用中引用了production.rb方法(尤其是初始化过程)?

答案 1 :(得分:0)

请设置Heroku Labs:user-env-compile by

heroku labs:enable user-env-compile -a myapp

https://devcenter.heroku.com/articles/labs-user-env-compile