Installing ruby gem less-rails on windows machine

2019-02-07 13:47发布

问题:

since a while I am trying to install the less-rails gem on my windows7 machine.

I already managed to install the needed therubyracer.gem using this binary file: https://github.com/stereobooster/therubyracer/downloads

I also downloaded the v8.dll and put in my ruby/bin directory. So far everything works well, the bundle install is running and the server starting without any problems.

But as soon as I request a page using a less file I get the following error message

undefined method `in_javascript?' for #"<"V8::Error: [object Object]>

My css.file is alomst empty

/*
*= require 'custom_less/custom'
*= require 'jquery-ui-1.8.24.custom'
*/

The custom.css.less looks like this

@import "twitter/bootstrap/reset";
@import "twitter/bootstrap/variables";
@import "custom_less/variables";                 // Your own variable overrides.
@import "twitter/bootstrap/mixins";
@import "custom_less/mixins";                    // Your own mixin.
@import "twitter/bootstrap/scaffolding";
@import "twitter/bootstrap/grid";
@import "twitter/bootstrap/layouts";
//import of further bootstrap components
//but nothing else

I am using the rails installer with ruby 1.9.3.

There are not many problem description like this. All I found was solved by updating to at least ruby 1.9.2. But that unfortunately is not the solution for me. Does somebody have an idea?

Thanks

回答1:

  1. Download this file: https://github.com/hiranpeiris/therubyracer_for_windows/archive/master.zip
  2. Extract it to a folder and cd to that folder.
  3. Install the gem file in that folder by gem install therubyracer*
  4. The folder has 2 dll files. Copy them to your ruby/bin folder.
  5. Add this to your Gemfile: `gem 'therubyracer'
  6. bundle install

Have fun.



回答2:

After a lot of research and trial and error it seems that less is not working on the windows plattform at the moment.

So my solution is to use the bootstrap-sass-rails gem instead. This is working pretty well.