Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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..

like image 795
Tim Baas Avatar asked Jul 17 '14 16:07

Tim Baas


2 Answers

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.

like image 183
Arctodus Avatar answered Oct 31 '22 09:10

Arctodus


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

like image 31
Neon_10 Avatar answered Oct 31 '22 09:10

Neon_10