Ruby on Rails error "cannot load such file -- less"

35,166

Solution 1

I guess you are using sass instead of LESS.

Have you tried the twitter-bootstrap-rails gem?

gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"

https://github.com/seyhunak/twitter-bootstrap-rails

Solution 2

I simply needed to restart my server.

I had added the three gems listed above (less-rails, therubyracer, and twitter-bootstrap-rails, with Rails 3.2.13) while my local server was running, resulting in the problem seen above. So once I shut it down and restarted it again, everything loaded well.

Solution 3

You have to either update therubyracer or downgrade the twitter-bootstrap-rails gem down to version 2.1.7 which is the last known version that didn't have this issue.

Run either bundle update to update your gems or in your Gemfile make your twitter-bootstrap-rails gem look like this:

gem 'twitter-bootstrap-rails', '2.1.7'

Take a look at this issue:

https://github.com/seyhunak/twitter-bootstrap-rails/issues/465

This issue started happening on versions after 2.1.7 on twitter-bootstrap-rails.

Solution 4

If you are getting it under Windows this should help you therubyracer_for_windows

It helped me

Solution 5

perhaps you are on windows ... there is no libv8 for windows and no binary therubyracer because it depends on libv8

Share:
35,166
Nicolas Brown
Author by

Nicolas Brown

a young jamaican with a passion for game design

Updated on July 09, 2022

Comments

  • Nicolas Brown
    Nicolas Brown almost 2 years

    I am fairly new to ruby on rails, I have been trying to use twitter-bootstrap as an asset, so I have included it in my Gemfile, bundled and it installs successfully. However I have noticed that it relies on certain dependencies that are not shown when I do the "bundle" command.

    The dependences it needs

    (1) Libv8
    (2) Less
    (3) Less-rails
    

    Error message:

    cannot load such file -- less
      (in c:/Sites/todo/app/assets/stylesheets/bootstrap_and_overrides.css.less)
    
    [code]
    
    Extracted source (around line #8):
    
    5:   <!--[if lt IE 9]>
    6:     <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"     type="text/javascript"></script>
    7:   <![endif]-->
    8:   <%= stylesheet_link_tag    "application", :media => "all" %>
    9:   <%= javascript_include_tag "application" %>
    10:   <%= csrf_meta_tags %>
    11:   <meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    [/code]
    
    Trace
    app/views/layouts/application.html.erb:8:in     `_app_views_layouts_application_html_erb__560528188_27183396'
    app/controllers/lists_controller.rb:7:in `index'
    

    I have noticed a lot of answers to this very question already, and have chosen the obvious solutions, but somehow I still get stuck, and would really appreciate some guidance.

  • Nicolas Brown
    Nicolas Brown over 11 years
    This is the gem that i am using currently, however i dont have the gem therubyracer or less-rails
  • Nicolas Brown
    Nicolas Brown over 11 years
    I try to install libv8 but it keeps failing, and the therubyracer depends on it, and also the "less" depends on the "therubyracer"
  • Helio Santos
    Helio Santos over 11 years
    I guess that's it... I've followed the guide on the link and it worked fine. Like I've said, rails uses SASS instead of LESS. That's why the other two gems are required. (I am using rails 3)
  • s2t2
    s2t2 almost 11 years
    @NicolasBrown try uninstalling and re-installing... gem uninstall libv8 then bundle install will detect the dependency of therubyracer and will install libv8. And restart your server, as was mentioned in another post.
  • max pleaner
    max pleaner about 10 years
    then why didnt you pick this as the correct answer?
  • ipatch
    ipatch almost 10 years
    @CodeBiker, yeah a restart was required for my rails app as well.
  • Andre Figueiredo
    Andre Figueiredo about 9 years
    Does not exist anymore (404 not found)