2015-05-21 77 views
2

所以,我通常不具備的應用程序部署到Heroku的,然而,在這種特定的情況下,我得到一個預編譯失敗的錯誤的任何問題......遙遠:!預編譯資產失敗。 (Heroku的)

這條線在這裏脫穎而出對我說:

remote:  NoMethodError: undefined method `[]' for nil:NilClass 

但這裏有完整的錯誤日誌:

remote:  Bundle completed (9.35s) 
remote:  Cleaning up the bundler cache. 
remote:  Removing carrierwave (0.10.0) 
remote:  Removing foreigner (1.7.4) 
remote:  Removing mailboxer (0.12.5) 
remote: -----> Preparing app for Rails asset pipeline 
remote:  Running: rake assets:precompile 
remote:  rake aborted! 
remote:  NoMethodError: undefined method `[]' for nil:NilClass 
remote:  (in /tmp/build_3dacd5df86a31726215c3dc3c1c22600/app/assets/stylesheets/application.css) 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/sass_functions.rb:63:in `sprockets_context' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-rails-4.0.5/lib/sass/rails/helpers.rb:23:in `asset_url' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/script/funcall.rb:113:in `_perform' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/script/node.rb:40:in `perform' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:298:in `visit_prop' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:100:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `block in visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `map' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:121:in `with_environment' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:108:in `visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `block in visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:356:in `visit_directive' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:100:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `block in visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `map' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:53:in `visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:121:in `with_environment' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:108:in `visit_children' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `block in visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:128:in `visit_root' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/base.rb:37:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:100:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/visitors/perform.rb:7:in `visit' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/tree/root_node.rb:20:in `render' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/engine.rb:315:in `_render' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sass-3.2.19/lib/sass/engine.rb:262:in `render' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/sass_compressor.rb:24:in `evaluate' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:197:in `block in evaluate' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `each' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `evaluate' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/bundled_asset.rb:25:in `initialize' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `new' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `build_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:211:in `block in find_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:257:in `benchmark' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:210:in `find_asset' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:119:in `block in compile' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `each' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `compile' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-2.12.3/lib/rake/sprocketstask.rb:146:in `with_logger' 
remote:  /tmp/build_3dacd5df86a31726215c3dc3c1c22600/vendor/bundle/ruby/2.2.0/gems/sprockets-rails-2.3.1/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define' 
remote:  Tasks: TOP => assets:precompile 
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 fakename-dev. 
remote: 
To [email protected]:fakename-dev.git 
! [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:fakename-dev.git' 

我在做什麼錯了,我怎麼能解決這個問題?

乾杯!

+0

你可以用'app/assets/stylesheets/application.css'的內容更新你的文章嗎?似乎這裏的東西正在產生錯誤。 –

+0

@steveklein application.css只包含基本的必需資產。該錯誤可能來自需要的某些文件,但我們無法找到它,它在生產ENV中的本地機器上編譯時沒有錯誤。 – rmagnum2002

+0

@steveklein,無論如何,這裏是https://gist.github.com/rmagnum2002/0a5fe0f2c8dbf2fda4ea – rmagnum2002

回答

4

這裏是這筆交易,我們有application.css,它以某種方式忽略了其他.scss文件中的預編譯錯誤,所以我們的資產預編譯在本地,但無法在heroku上預編譯它們。

我決定當我運行assets:precompile任務我得到的錯誤一樣在Heroku重命名application.cssapplication.css.scss現在,這讓我來調查問題出在哪裏了。

這是縮小的一個文件bootstrap.css(從設計師來了),在我們的團隊開發決定對其縮排,重新因子和改變路徑,字體不改變擴展.scss得到image-urlasset-url助手可用..無論如何,我放棄了所有這一切,並使用引導寶石,解決了圖標的問題。

總結一下,將.scss添加到您的樣式表中,以便在預編譯時快速找到問題所在。

0

運行命令:RAILS_ENV=production bundle exec rake assets:precompile,您可以輕鬆地排除錯誤。

+1

我們做了這麼多次,並且每次都是預先編譯成功,只是將清單重命名爲'.scss'返回與heroku相同的錯誤。 – rmagnum2002