Ruby on Rails错误“无法加载此类文件- less”

时间:2021-10-01 09:47:41

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.

我是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.

我已经注意到这个问题的许多答案,并选择了显而易见的解决方案,但不知何故,我还是被困住了,希望能得到一些指导。

5 个解决方案

#1


89  

I guess you are using sass instead of LESS.

我猜你是在用sass而不是更少。

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

#2


26  

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和twitter-bootstrap-rails,使用Rails 3.2.13),导致了上面看到的问题。所以一旦我关闭它,重新启动它,一切都很好。

#3


7  

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.

你要么更新therubyracer,要么将twitter-bootstrap-rails gem降级到2.1.7版本,这是最后一个没有这个问题的版本。

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

运行包更新来更新您的gem或者在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.

这个问题在twitter-bootstrap-rails 2.1.7之后的版本中开始出现。

#4


4  

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

如果你在Windows下获取它,这将帮助你访问therubyracer_for_windows

It helped me

它帮助我

#5


1  

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

也许你在窗户上……windows没有libv8,也没有二进制therubyracer,因为它依赖于libv8

#1


89  

I guess you are using sass instead of LESS.

我猜你是在用sass而不是更少。

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

#2


26  

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和twitter-bootstrap-rails,使用Rails 3.2.13),导致了上面看到的问题。所以一旦我关闭它,重新启动它,一切都很好。

#3


7  

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.

你要么更新therubyracer,要么将twitter-bootstrap-rails gem降级到2.1.7版本,这是最后一个没有这个问题的版本。

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

运行包更新来更新您的gem或者在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.

这个问题在twitter-bootstrap-rails 2.1.7之后的版本中开始出现。

#4


4  

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

如果你在Windows下获取它,这将帮助你访问therubyracer_for_windows

It helped me

它帮助我

#5


1  

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

也许你在窗户上……windows没有libv8,也没有二进制therubyracer,因为它依赖于libv8