Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

image_url is undefined method `[]' for nil:NilClass #98

Closed
pacovell opened this issue Mar 12, 2012 · 19 comments
Closed

image_url is undefined method `[]' for nil:NilClass #98

pacovell opened this issue Mar 12, 2012 · 19 comments

Comments

@pacovell
Copy link

Using the 3.2.4 gem, only in production on first query; subsequent queries work fine

NoMethodError (undefined method `[]' for nil:NilClass):
  vendor/bundle/ruby/1.9.1/gems/sass-rails-3.2.4/lib/sass/rails/helpers.rb:32:in `resolver'
  vendor/bundle/ruby/1.9.1/gems/sass-rails-3.2.4/lib/sass/rails/helpers.rb:25:in `image_url'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/funcall.rb:88:in `_perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/node.rb:40:in `perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `block in _perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `_perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/node.rb:40:in `perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `block in _perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/list.rb:69:in `_perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/script/node.rb:40:in `perform'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:216:in `visit_prop'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:201:in `block (2 levels) in visit_mixin'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:201:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:201:in `block in visit_mixin'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:201:in `visit_mixin'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:238:in `visit_rule'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:238:in `visit_rule'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:238:in `visit_rule'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `block in visit_import'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `visit_import'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `block in visit_import'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:146:in `visit_import'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `map'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:53:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:27:in `block in visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:39:in `with_environment'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:26:in `visit_children'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `block in visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:47:in `visit_root'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/base.rb:37:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:18:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/visitors/perform.rb:7:in `visit'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/tree/root_node.rb:20:in `render'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/engine.rb:299:in `_render'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/engine.rb:246:in `render'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:339:in `update_stylesheet'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:202:in `block in update_stylesheets'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:200:in `each'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin/compiler.rb:200:in `update_stylesheets'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin.rb:81:in `update_stylesheets'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin.rb:54:in `check_for_updates'
  vendor/bundle/ruby/1.9.1/gems/sass-3.1.15/lib/sass/plugin/rack.rb:51:in `call'
  vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:35:in `block in call'
  vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:in `catch'
  vendor/bundle/ruby/1.9.1/gems/warden-1.1.1/lib/warden/manager.rb:34:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/conditionalget.rb:25:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/head.rb:14:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/params_parser.rb:21:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/flash.rb:242:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:205:in `context'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/session/abstract/id.rb:200:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/cookies.rb:338:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:28:in `block in call'
  vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `_run__3718529300652309739__call__2905389853994320807__callbacks'
  vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:405:in `__run_callback'
  vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:385:in `_run_call_callbacks'
  vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/callbacks.rb:81:in `run_callbacks'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/remote_ip.rb:31:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/debug_exceptions.rb:16:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/show_exceptions.rb:56:in `call'
  vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:26:in `call_app'
  vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/rack/logger.rb:16:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/request_id.rb:22:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/methodoverride.rb:21:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/runtime.rb:17:in `call'
  vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.1/lib/active_support/cache/strategy/local_cache.rb:72:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/lock.rb:15:in `call'
  vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.1/lib/action_dispatch/middleware/static.rb:53:in `call'
  vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:136:in `forward'
  vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:245:in `fetch'
  vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:185:in `lookup'
  vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:66:in `call!'
  vendor/bundle/ruby/1.9.1/gems/rack-cache-1.2/lib/rack/cache/context.rb:51:in `call'
  vendor/bundle/ruby/1.9.1/gems/airbrake-3.0.9/lib/airbrake/user_informer.rb:12:in `call'
  vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/engine.rb:479:in `call'
  vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/application.rb:220:in `call'
  vendor/bundle/ruby/1.9.1/gems/railties-3.2.1/lib/rails/railtie/configurable.rb:30:in `method_missing'
  vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/static.rb:66:in `call'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:80:in `block in pre_process'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:78:in `catch'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:78:in `pre_process'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:53:in `process'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/connection.rb:38:in `receive_data'
  vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
  vendor/bundle/ruby/1.9.1/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/backends/base.rb:61:in `start'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/server.rb:159:in `start'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/controllers/controller.rb:86:in `start'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:185:in `run_command'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/lib/thin/runner.rb:151:in `run!'
  vendor/bundle/ruby/1.9.1/gems/thin-1.3.1/bin/thin:6:in `<top (required)>'
  vendor/bundle/ruby/1.9.1/bin/thin:19:in `load'
  vendor/bundle/ruby/1.9.1/bin/thin:19:in `<main>'
@chriseppstein
Copy link
Contributor

Ugh. it looks like the Sass::Plugin rack adapter is running.

@chriseppstein
Copy link
Contributor

As a work around: Sass::Plugin.options[:never_update] = true

@pacovell
Copy link
Author

Yes, the workaround, er.. works. Thanks.

@antage
Copy link

antage commented Apr 17, 2012

I have same problem with sass-rails 3.2.5

@antage
Copy link

antage commented Apr 17, 2012

When I invoke rake assets:precompile --trace then got this backtrace https://gist.github.com/ea171db6f9e2a6e215ef
Workaround Sass::Plugin.options[:never_update] = true in config/initializers/sass_rails.rb doesn't help me.

@aaronjensen
Copy link

I also get a similar stack trace with 3.2.5

@aaronjensen
Copy link

the problem seems to have to do with requiring or importing regular css files that have image-url in them, which makes sense, those aren't valid css. It's a deceptive error though. It's because the compressor uses scss, but only sets it up with hard coded options and it doesn't use the same defaults.

@chriseppstein
Copy link
Contributor

Uh. How would that work? The issues is that the scss compressor is expecting that to have been handled already. Please don't use sass functions in CSS files ;)

Hunt & pecked on my iPhone... Sorry if it's brief!

On Apr 17, 2012, at 4:44 PM, Aaron Jensenreply@reply.github.com wrote:

the problem seems to have to do with requiring or importing regular css files that have image-url in them


Reply to this email directly or view it on GitHub:
#98 (comment)

@aaronjensen
Copy link

Excellent question.. not sure how it would work, but it did before I upgraded to the asset pipeline and rails/sass 3.2 shrug I renamed the file to scss and it's all good now.

On Tuesday, April 17, 2012 at 5:36 PM, Chris Eppstein wrote:

Uh. How would that work? The issues is that the scss compressor is expecting that to have been handled already. Please don't use sass functions in CSS files ;)

Hunt & pecked on my iPhone... Sorry if it's brief!

On Apr 17, 2012, at 4:44 PM, Aaron Jensen<reply@reply.github.com (mailto:reply@reply.github.com)> wrote:

the problem seems to have to do with requiring or importing regular css files that have image-url in them


Reply to this email directly or view it on GitHub:
#98 (comment)


Reply to this email directly or view it on GitHub:
#98 (comment)

@antage
Copy link

antage commented Apr 18, 2012

You're right guys. It's my fault, I used image-url in plain-css file.
It may be worth to add some checks or more descriptive error message?

@davesmylie
Copy link

I'm getting the same issue/stack-trace with sass-rails 3.2.5. I've tried the Sass::Plugin.options[:never_update] = true workaround, but seems to have had no effect.

As far as I can tell I'm not using image-url at all in any files:

~/code/satest (master) $ grep image app/assets/* -R
app/assets/stylesheets/base.scss:      background-image: none;
app/assets/stylesheets/base.scss:    background-image: url(/images/gradient_incorrect.png); }

I'm guessing maybe it's pulling in a css file from a plugin or other gem (eg devise). Is it possible to see what file it's processing when it falls over?

@davesmylie
Copy link

My bad - that stack trace turned out to be from precompiled asset file rather than something current. (That will teach me for just looking at it in the browser rather than going back to the filesystem to confirm...)

@geetarista
Copy link

I'm having the same issue, and it seems to be a combination of this and #94.

I have a partial scss file that has some ERB in it to do an iteration through all the themes we have. In order to get around the problem in #94, the file is called _theme_swatches.css.erb. However, this causes me to get the undefined method[]' for nil:NilClass` error noted above.

Is there a workaround that I can use for now?

@castus
Copy link

castus commented Nov 8, 2012

The same here when sprites are generated - Compass/compass-rails#67

@castus
Copy link

castus commented Nov 9, 2012

I found a simple workaround

https://gist.github.com/4044953

@frodsan
Copy link
Contributor

frodsan commented Apr 19, 2013

Is this still an issue?

@frodsan
Copy link
Contributor

frodsan commented Apr 30, 2013

Same as #121.

@frodsan frodsan closed this as completed Apr 30, 2013
@edrex
Copy link

edrex commented Jun 2, 2013

Yes, still an issue. Is it closed because there is a fix released in rails 4? People will be running 3.2 for some time.

@abhiyan52
Copy link

This problem occurs when you use .css file instead of .scss

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants