Asset compiling crashing on server environment with: “NoMethodError: undefined method `[]' for nil:NilClass”

ⅰ亾dé卋堺 提交于 2019-12-18 12:13:08

问题


I've been pulling my hair out for this one. I've always had a bad relationship with the asset-pipeline, it is always giving me trouble.. And today again..

When I try and compile my assets locally, everything is fine:

$ RAILS_ENV=production rake assets:precompile --trace

But when I deploy with Capistrano which does:

cd /var/www/xxx/releases/20140717164232 && ( RAILS_ENV=production bundle exec rake assets:precompile )

It crashes with the following error:

rake aborted!
NoMethodError: undefined method `[]' for nil:NilClass
  (in /var/www/xxx/releases/20140717164232/app/assets/stylesheets/application-sign-in.css)
/var/www/xxx/shared/bundle/ruby/2.1.0/gems/sprockets-2.11.0/lib/sprockets/sass_functions.rb:63:in `sprockets_context'

I seriously do not know how to debug this.. Locally I can't reproduce it and on my server the error is just not pointing me anywhere..

I've searched for the error and tried a couple things but nothing helped. Some say the error is going away by updating.. Or by adding the sprockets gem before the sass-rails gem.

My project is setup like the following; A regular rails 4 app with a gem containing assets representing a template. I use the following line to make sure everything is compiled:

config.assets.precompile += %w(*.png *.jpg *.jpeg *.gif *.css *.js *.eot *.woff *.ttf *.svg)

Anyone that knows how to solve this, or how to debug it?

EDIT

Removing all asset-url() helper seems to work.. But again, no clue why..


回答1:


I had the samme issue and it turned out to be a css file containing asset-url that didnt have the .scss extension. Weirdly I could compile the assets locally but not on the server.




回答2:


the problem is because of .css extension instead of .scss. I have changed it on .scss and it worked.




回答3:


Heroku has a post about this. Precompile it locally and add all those files especially /public/assets/manifest.yml. Heroku should ignore pre compilation and proceed.



来源:https://stackoverflow.com/questions/24809432/asset-compiling-crashing-on-server-environment-with-nomethoderror-undefined-m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!