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

NoMethodError undefined method `[]' for "image":Sass::Script::Value::String #279

Open
jrochkind opened this issue Sep 30, 2015 · 10 comments
Open

Comments

@jrochkind
Copy link

@jrochkind jrochkind commented Sep 30, 2015

I am getting this one. I haven't yet figured out where it's coming from in the source SCSS.

But the last linse in the stacktrace are:

 sprockets-rails-2.3.3/lib/sprockets/rails/helper.rb:88:in `asset_path'
 sprockets-3.3.5/lib/sprockets/sass_processor.rb:112:in `asset_path'
 sprockets-3.3.5/lib/sprockets/sass_processor.rb:125:in `asset_url'

Anyone have any idea what's going on, or suggestions for how I might debug this further? I'm not sure where to go from here -- or even how to figure out what line in source SASS is triggering this.

@jrochkind

This comment has been minimized.

Copy link
Author

@jrochkind jrochkind commented Sep 30, 2015

Okay, I had to force downgrade sprockets to latest 2.x (2.12.4) and downgrade sprockets-rails to 2.3.2.

Despite the fact that sprockets-rails 2.3.3 and 2.3.2 both say they should work with sprockets [">= 2.8", "< 4.0"] -- that was the only combination I could get that would actually compile my Sass.

  • Downgrading to sprockets-rails 2.3.2 but still sprockets 3.3.5, same error as above.
  • Downgrading to sprockets 2.12.4 but still sprockets-rails 2.3.3, instead I get a wrong number of arguments (2 for 1) forasset-url' `, although at least it gives me a Sass line number, that indeed is using a two-arg asset-url (but isn't that still supposed to be allowed if deprecated?)

Downgrading both, my Sass compiles again.

I have no idea if this is a bug in sprockets, sprockets-rails, both, neither, whatever. This is super confusing.

I don't like having to lock to older versions of sprockets and sprockets-rails in my Gemfile.

Any ideas? This is pretty confusing.

@rafaelfranca

This comment has been minimized.

Copy link
Member

@rafaelfranca rafaelfranca commented Oct 2, 2015

Can you please provide a sample application that reproduces the error?

@jrochkind

This comment has been minimized.

Copy link
Author

@jrochkind jrochkind commented Oct 2, 2015

Oh boy, it's a LOT of SCSS from a couple gems, including bootstrap-sass, an engine gem, and local scss. I'll see if I can isolate it somehow.

@andvikram

This comment has been minimized.

Copy link

@andvikram andvikram commented Oct 13, 2015

I am also facing this problem. I am using the following:

Ruby: 2.2.2
Rails: 4.2.4
Sprockets: 3.4.0
Sprockets-rails: 2.3.3

My project is actually an upgrade from Rails 3 and Ruby 1.9.

@jrochkind

This comment has been minimized.

Copy link
Author

@jrochkind jrochkind commented Oct 13, 2015

Okay, I never completely got to the bottom of this and created an isolated reproduction.

However, it appears to be working for me without this error now, with latest versions of sprockets and sprockets-rails allowed by Rails 4.2.4 -- sprockets 3.4.0, and sprockets-rails 2.3.3 -- I think those are the same versions I was using when I had the problem I originally reported here though.

One thing I did change: I still had some lines in my scss that used the old two-argument asset-url, eg: asset-url($asset_name_variable, image)

I thought this two argument from was deprecated but still allowed? However, the two argument from was sometimes, unpredictably giving me errors "Wrong number of arguments, 2 for 1", and other times working -- I can't explain it. It seemed to even depend on the Rails environment in use (I have a 'staging' environment i created myself, whose environments/staging.rb is just a copy of production.rb, but which has different database.yml and other config).

I don't know if that could have also been responsible for this error, but since I fixed the two-arg asset-url's to one... I don't seem to have seen it. Hopefully it will stay that way. If it comes back, I'll add another comment.

@andvikram

This comment has been minimized.

Copy link

@andvikram andvikram commented Oct 14, 2015

The solutions provided by @jrochkind works for me as well. I downgraded sprockets to 2.12.4 and sprockets-rails to 2.3.2.

atz added a commit to sul-dlss/bassi_veratti that referenced this issue Oct 26, 2016
Shout-out to @jrochkind, who is, as usual, cutting a path through my
current difficulties approximately 1 year into the future.
rails/sprockets-rails#279 (comment)
@hendricius

This comment has been minimized.

Copy link
Contributor

@hendricius hendricius commented Nov 10, 2016

Do you guys still have this issue? Downgrading sprockets did not work for me.

@hendricius

This comment has been minimized.

Copy link
Contributor

@hendricius hendricius commented Nov 10, 2016

Ok - in my case It was me having a scss file that still used asset-url. Replacing it with the new image-url syntax made things work again.

@bparanj

This comment has been minimized.

Copy link

@bparanj bparanj commented Dec 14, 2016

I am suffering from the same problem for upgrade from Rails 3.2 to Rails 4.2. Ruby : 2.3.1. The following gems:

gem 'sprockets', '3.4'
gem 'sprockets-rails', '2.3.3'

does not resolve the problem.

@marcosserpa

This comment has been minimized.

Copy link

@marcosserpa marcosserpa commented Mar 1, 2017

From the time you commented, probably you resolved. But, to future guys, I think this can be your problem. This resolved to me, when upgrading my app from 3.2 to 4.2 too:

http://edgeguides.rubyonrails.org/upgrading_ruby_on_rails.html#sass-rails

asset-url with two arguments is deprecated. For example: asset-url("rails.png", image) becomes asset-url("rails.png").

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

Successfully merging a pull request may close this issue.

None yet
6 participants
You can’t perform that action at this time.