简体   繁体   中英

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.

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

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.

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 .

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

It helped me

也许你在Windows上...没有libv8 for windows和没有二进制therubyracer因为它依赖于libv8

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM