assets:precompile with .less files strange behavior #306

mokagio opened this Issue Mar 17, 2012 · 3 comments

2 participants


I found myself in front of a strange behavior of the assets:precompile task, or at least in front of something I don't fully understand. I don't event know if this is the right place to ask, if it isn't please forgive me.

So, I am using Rails 3.1.3, Sprockets 2.0.3, Less 2.0.11 for my web application, plus I rely on Bootstrap for the layout, so I am using also less-rails 2.1.8 and less-rails-bootstrap 2.0.8.
I have customized the style like they say here.

The configuration of my assets is:


In application.css.scss I do

//=require custom-style

And in custom-style I do

@import "twitter/bootstrap/reset";
//@import "twitter/bootstrap/variables"; // Modify this for custom colors, font-sizes, etc
@import "custom-style/variables";
//@import "twitter/bootstrap/mixins";
@import "custom-style/mixins";
// And all the other standar twitter/bootstrap imports...

// Other custom-style files to import
@import "custom-style/buttons"

// And other rules here

Finally in buttons.less I use some variables and mixins defined in the variables.less and mixins.less files, @white and .buttonBackground to be more specifc.

If I launch bundle exec rake assets:precompile with the above configuration, the task fails and I get this error:

$ bundle exec rake assets:precompile
/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby /usr/local/rvm/gems/ruby-1.9.3-p0/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
.buttonBackground is undefined

But is that if I do this changes

buttons.less --> buttons.css.less

@import "buttons"  --> @import "buttons.css.less"

Everything works fine!!

Is it something related to the scope of less variables and functions when working with nested imports? Or something that has to do with the order the less parser, or Sprockets, processes the import tree?

Am I missing something or doing something in the wrong way?

Thanks :)

Note: I get the error even with the original variables and mixins files, so it's not connected with the overrides done into them.


There seems to be a few violations of how I proposed customization in the demo less-rails-bootstrap test project. I got to the part in your issue where custom-style is already named wrong. It should just be a manifest and be named custom-style.css with no .less extension. So can you reconfirm you are using the methods I described in the test project open a ticket if needed on less-rails-bootstrap. I kind of doubt this is a core sprockets issue.


Ok! I'll look at it once home from work. I'll let you know. Thanks ;)


-.- sorry, it has been really a while...

I swapped to your less-rails-bootstrap-test approach and everything worked fine.

I'd really like to be able to look into the matter and fully understand how this works in the background, but I just do not have time right now :/


@mokagio mokagio closed this May 7, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment