livingstyleguide / livingstyleguide

Easily create front-end style guides with Markdown and Sass/SCSS.
https://livingstyleguide.org/
Other
871 stars 81 forks source link

Sass::Rails::Resolver not found on heroku #105

Closed RalphAtHamburg closed 9 years ago

RalphAtHamburg commented 9 years ago

After updating to rails 4.2 , sass-rails 5.1, compass 1.01 (via compas-rails) deploying to heroku causes the following error:

rake aborted!
     NameError: uninitialized constant Sass::Rails::Resolver
     (in /tmp/build_a38d96060def891adae51ce05faf5635/app/assets/stylesheets/styleguide.html.lsg)
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/livingstyleguide-1.2.1/lib/livingstyleguide/tilt_template.rb:44:in `sass_options'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/livingstyleguide-1.2.1/lib/livingstyleguide/tilt_template.rb:94:in `render_living_style_guide'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/livingstyleguide-1.2.1/lib/livingstyleguide/tilt_template.rb:16:in `evaluate'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/tilt-1.4.1/lib/tilt/template.rb:103:in `render'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:197:in `block in evaluate'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `each'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/context.rb:194:in `evaluate'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/processed_asset.rb:12:in `initialize'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `new'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:374:in `block in build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:395:in `circular_call_protection'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:373:in `build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/bundled_asset.rb:16:in `initialize'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `new'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:377:in `build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:94:in `block in build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/caching.rb:58:in `cache_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:93:in `build_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/base.rb:287:in `find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/index.rb:61:in `find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:211:in `block in find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:257:in `benchmark'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:210:in `find_asset'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:119:in `block in compile'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `each'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/sprockets/manifest.rb:118:in `compile'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/non-stupid-digest-assets-1.0.4/lib/non-stupid-digest-assets.rb:31:in `compile_with_non_digest'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.2/lib/sprockets/rails/task.rb:70:in `block (3 levels) in define'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-2.12.3/lib/rake/sprocketstask.rb:146:in `with_logger'
     /tmp/build_a38d96060def891adae51ce05faf5635/vendor/bundle/ruby/2.1.0/gems/sprockets-rails-2.2.2/lib/sprockets/rails/task.rb:69:in `block (2 levels) in define'

The local development environment works fine. Maybe it’s something with compass. Commenting out "@import compass" in application.css.scss shows the same error in the development environment.

kangguru commented 9 years ago

looks like this is coming from 59c77249f91d21c700b58baa836941f43ba3b43f as theres no Resolver in sass-rails since... downgrading to 1.2.0 helps :)

hagenburger commented 9 years ago

@kangguru thanks for pointing that out! Do you maybe have a fix for that? I’m not working with any Rails 4.x right now.

RalphAtHamburg commented 9 years ago

Just found some time have a closer look at this issue. The problem wasn't the move from rails 4.1 -> 4.2. As @kangguru mentioned its coming from 59c7724 Reverting the changes solves the error. I am wondering if we can revoke this commit?

hagenburger commented 9 years ago

I would suggest we need some test cases. @derfred could you join the discussion?

derfred commented 9 years ago

ok I'll look into it. My change was due to using image-path which failed in the precompile step. The lookup here (hence the Resolver class) must have changed.

I won't be able to do this today, but definitely this week.

kangguru commented 9 years ago

yea. somthing has been changed there. first step should be to extend the check existence of Sass::Rails::Resolver but is seems like we need to come up with something for sass-rails > 3.x

@derfred where did you use image-path? in a stylesheet or the styleguide

derfred commented 9 years ago

@kangguru in a stylesheet. I only tried it in a Rails 3.2 app with sass-rails 3.2.5.

RalphAtHamburg commented 9 years ago

This commit removes the resolver https://github.com/rails/sass-rails/commit/d357b0194015b05bf54f25ab7be6d6add5a91d1f

derfred commented 9 years ago

Please check #106.

So here's the story: In sass-rails < 4.0 the asset path helpers like image-url were implemented in sass-rails with the help of the Resolver class. In 4.0 those helpers delegate to sprockets. Now in 5.0 the resolver which was no longer used is removed.

@kangguru I think just extending the existence check like I did in my pull request is sufficient. I tested the following combinations:

They all work and do the right thing, ie embed the correct asset url.

kangguru commented 9 years ago

cool thing! thx for the effort to check it out on different versions of sass-rails

hagenburger commented 9 years ago

Thank you, awesome! :)

@kangguru @RalphAtHamburg would you mind testing it before I release?

kangguru commented 9 years ago

works for me :) as far as i can tell.

this is something i have in my stylesheet:

&.as-mobile
    +retina-background(image-path('leistungen_mobile.jpg'), image-path('leistungen_mobile@2x.jpg'))

this is how i use it in the styleguide

%li
  .a-hero-list-box.as-mobile
    .a-hero-list-box--title Mobile Foo

yields no error. @derfred this the usecase when you encountered the issue, correct?

derfred commented 9 years ago

@kangguru yes that was my exact use case.

RalphAtHamburg commented 9 years ago

works for me:

kangguru commented 9 years ago

\o/

woi-workstation commented 9 years ago

i'm using rails 4.1.6, sass-rails 5.0.1, sprockets 2.12.3 but still got uninitialized constant Sass::Rails::Resolver it seem **Sass::Rails::Resolver"" only exist in sass-rails >= 3.x

kangguru commented 9 years ago

hm, are you using the correct reference in your Gemfile?

https://github.com/konvenit/livingstyleguide/tree/fix_the_fix_of_the_fix

this fix isn't yet in hagenburger/master

hagenburger commented 9 years ago

I’ll prepare a release right now :)

hagenburger commented 9 years ago

Done: http://livingstyleguide.org/changelog.html#1.2.2

hagenburger commented 9 years ago

I had a deep look into sprockets, sprockets-rails, sass-rails, tilt, and middleman which led into a complete refactoring. Having the new code, LSG should render Sass exactly the same way Rails/Middleman does and provide access to all helpers and load paths. The fix for this issue should be obsolete. But it needs to be tested with different Rails version combinations.

This will be available from 2.0.0.alpha.3 on.

RalphAtHamburg commented 9 years ago

I just started porting the desksurfing LGS to the new LSG2 style, so we will have it tested on Rails 4.2 (ruby 2.2)

hagenburger commented 9 years ago

@RalphAtHamburg looking forward to hear your experiences!