Skip to content
This repository

3.1.2 Asset pipeline not recognizing file changes in @import 'ed files #3686

Closed
jess opened this Issue · 20 comments

13 participants

Jess Brown Jason Earl Corné Verbruggen murdoch Jon Leighton Jean Mertz Joshua Peek Nate Wiger Cailin Nelson Chris Eppstein Andy Zhang Jakob Hilden jack dempsey
Jess Brown

Say you have app/stylesheets/home.css.scss:

@import "partials/base";
body {
  background: $color;
}

And you have app/stylesheets/partials/_base.scss:

$color: red;

First compile will work fine. If you change anything in the _base.scss
file, home.css will not be updated. On refresh.

Works fine in rails 3.1.1

Here's a demo

*Both apps are identical fresh rails apps except the versions

'#cache #development #sass #import #update #refresh

Jason Earl

Yes, affects me too. Have rolled back to 3.1.1, otherwise it gets frustrating clearing the browser cache.

Corné Verbruggen

Can confirm this

murdoch

Can confirm this too. With and without guard-livereload.

I'm on Ubuntu 11.10, using MRI-1.9.2

Jon Leighton
Owner

cc @josh. can you shed any light on this?

Jean Mertz

I just ran into this as well. Rolling back to 3.1.1 solved the issue.

Joshua Peek
Collaborator

i dunno the sass rails plugin handles all this

Jon Leighton
Owner

Possibly related: rails/sass-rails#70

Nate Wiger

just adding a "me too" seeing the exact same thing

Jon Leighton
Owner

@josh, it's not a sass-rails issue. it's a sprockets issue.

Rails 3.1.1 (sprockets 2.0):

Loading development environment (Rails 3.1.1)
ruby-1.9.3-p0 :001 > a = Rails.application.assets["application.css.scss"]
 => #<Sprockets::BundledAsset:0x253f6e0 pathname="/home/turnip/Desktop/testapp/app/assets/stylesheets/application.css.scss", mtime=2011-11-20 19:04:37 +0000, digest="ae1905e1935c7263656201f82d5f6ddf"> 
ruby-1.9.3-p0 :002 > [a.digest, a.mtime]
 => ["ae1905e1935c7263656201f82d5f6ddf", 2011-11-20 19:04:37 +0000] 
ruby-1.9.3-p0 :003 > # @import-ed file changed
ruby-1.9.3-p0 :004 >   a = Rails.application.assets["application.css.scss"]
 => #<Sprockets::BundledAsset:0x2634f14 pathname="/home/turnip/Desktop/testapp/app/assets/stylesheets/application.css.scss", mtime=2011-11-20 19:18:41 +0000, digest="ed04c928b1a895b5c76f74b974cbf608"> 
ruby-1.9.3-p0 :005 > [a.digest, a.mtime]
 => ["ed04c928b1a895b5c76f74b974cbf608", 2011-11-20 19:18:41 +0000] 

(Note that the mtime changes)

Rails 3.1.2 (sprockets 2.1):

Loading development environment (Rails 3.1.2)
ruby-1.9.3-p0 :001 > a = Rails.application.assets["application.css.scss"]
 => #<Sprockets::BundledAsset:0x202ce78 pathname="/home/turnip/Desktop/testapp/app/assets/stylesheets/application.css.scss", mtime=2011-11-20 18:55:58 +0000, digest="8186eb54523013995ef0198551cc00a2"> 
ruby-1.9.3-p0 :002 > [a.digest, a.mtime]
 => ["8186eb54523013995ef0198551cc00a2", 2011-11-20 18:55:58 +0000] 
ruby-1.9.3-p0 :003 > # @import-ed file changed
ruby-1.9.3-p0 :004 >   a = Rails.application.assets["application.css.scss"]
 => #<Sprockets::BundledAsset:0x20274dc pathname="/home/turnip/Desktop/testapp/app/assets/stylesheets/application.css.scss", mtime=2011-11-20 18:55:58 +0000, digest="350a879fea2aa6fa3be0a031abd1be58"> 
ruby-1.9.3-p0 :005 > [a.digest, a.mtime]
 => ["350a879fea2aa6fa3be0a031abd1be58", 2011-11-20 18:55:58 +0000] 

(Note that the mtime does not change)

Joshua Peek
Collaborator

That is a sass rails issue.

Jess Brown

** I didn't get/see @josh 's comment until after I posted...

thanks for confirming @jonleighton

I had a hunch it was a sprockets issue because of the version change in sprockets and I didn't see anything in the rails commits or sass-rails that should affect it.

I sent @sstephenson a tweet Saturday asking if he thought it could be a sprockets issue, but haven't heard back yet.

There's been a lot of changes to the find_asset method dealing with caching and the fresh? method (https://github.com/sstephenson/sprockets/commits/master/lib/sprockets/environment.rb), but don't know enough to determine if that's the area of the problem.

Sorry don't know the protocol, should the issue be filed with sprockets?

Jon Leighton
Owner

@josh care to elaborate? sass-rails has barely changed from 3.1.4 to 3.1.5, whilst sprockets has changed quite a bit. I don't actually know how all these things fit together, I am just trying to work out a solution. Could do with some help.

Joshua Peek
Collaborator

I think it might be using the wrong apis.

https://github.com/rails/sass-rails/blob/master/lib/sass/rails/importer.rb#L48

Think thats supposed to be depend_on_asset.

Jon Leighton
Owner

@josh that didn't fix it.

I've made a sprockets pull request: sstephenson/sprockets#247 which fixes it. Unsure whether it's "correct" but let's see what you think.

Cailin Nelson

I'm not sure if this is a "workaround" or the "correct solution", but the following worked for me: http://stackoverflow.com/questions/7046495/rails-3-1-asset-pipeline-doesnt-pick-up-changes-to-importd-sheets

Chris Eppstein

The sass-rails implementation of @import calls depend_on for you:

https://github.com/rails/sass-rails/blob/master/lib/sass/rails/importer.rb#L48
https://github.com/rails/sass-rails/blob/master/lib/sass/rails/importer.rb#L87

So the recommendation of the stack overflow post should not be necessary.

Andy Zhang

Still having issues with this. On sass-rails 3.2.5, but it looks it's on sprockets 2.1. Thoughts?

Jakob Hilden

@ZhangBanger as far as I can tell, the only thing you can do right now is to wait for a new rails 3.2.x release that will update the sprockets dependency or to switch to the current '3-2-stable' (which is probably not advisable for production apps).

See also here:
sstephenson/sprockets#336 (comment)

jack dempsey

@cailinanne wow, thank you, been banging my head against the wall for a while on that one. Now I can actually get back to coding. Much appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.