Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 689
Nicolas Brown Avatar asked Dec 15 '12 01:12

Nicolas Brown


4 Answers

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

like image 181
Helio Santos Avatar answered Oct 19 '22 17:10

Helio Santos


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.

like image 38
CodeBiker Avatar answered Oct 19 '22 18:10

CodeBiker


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.

like image 7
Leo Correa Avatar answered Oct 19 '22 19:10

Leo Correa


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

It helped me

like image 4
w_g Avatar answered Oct 19 '22 18:10

w_g