Ruby on Rails 错误“无法加载此类文件——更少”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13888381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 21:11:21  来源:igfitidea点击:

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

ruby-on-railsrubytwitter-bootstrapweb

提问by Nicolas Brown

I am fairly new to ruby on rails, I have been trying to use twitter-bootstrapas 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.

我是相当新的ruby on rails,我一直在尝试使用twitter-bootstrap作为一项资产,所以我在Gemfile中包含它,捆绑并成功安装。但是我注意到它依赖于我执行“bundle”命令时未显示的某些依赖项。

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.

我已经注意到这个问题的很多答案,并选择了明显的解决方案,但不知何故我仍然被卡住,并且非常感谢一些指导。

回答by Helio Santos

I guess you are using sass instead of LESS.

我猜你正在使用 sass 而不是 LESS。

Have you tried the twitter-bootstrap-rails gem?

您是否尝试过 twitter-bootstrap-rails gem?

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

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

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

回答by CodeBiker

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.

我在本地服务器运行时添加了上面列出的三个 gem(less-rails, therubyracer, and twitter-bootstrap-rails, 和Rails 3.2.13),导致了上面看到的问题。所以一旦我关闭它并再次重新启动它,一切都加载良好。

回答by Leo Correa

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

您必须therubyracertwitter-bootstrap-railsgem更新或降级到版本 2.1.7,这是最后一个没有此问题的已知版本。

Run either bundle updateto update your gems or in your Gemfilemake your twitter-bootstrap-rails gem look like this:

运行bundle update以更新您的 gems 或Gemfile让您的 twitter-bootstrap-rails gem 看起来像这样:

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

Take a look at this issue:

看看这个问题:

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

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

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

这个问题开始发生在 2.1.7 之后的版本上twitter-bootstrap-rails

回答by w_g

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

如果您在 Windows 下获得它,这应该对您有帮助 therubyracer_for_windows

It helped me

它帮助了我

回答by Bernhard Zürn

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

也许您在 Windows 上……没有用于 Windows 的 libv8,也没有二进制 therubyracer,因为它依赖于 libv8