twitter-bootstrap 'twitter/bootstrap/bootstrap.less' 未找到
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16665642/
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
'twitter/bootstrap/bootstrap.less' wasn't found
提问by Askar
I was trying to play with Twitter Bootstrap Basicsusing Rails 4.0.0.rc1 and ruby 1.9.3p392.
我试图使用 Rails 4.0.0.rc1 和 ruby 1.9.3p392来玩 Twitter Bootstrap Basics。
Then I try to access
http://localhost:3000/products
然后我尝试访问
http://localhost:3000/products
I'm having error:
我有错误:
'twitter/bootstrap/bootstrap.less' wasn't found.
没有找到“twitter/bootstrap/bootstrap.less”。
Please see attached screenshot.
请参阅附件截图。
Code available at https://github.com/tenzan/twitter-bootstrap.git
代码可在https://github.com/tenzan/twitter-bootstrap.git


采纳答案by shrikant1712
You have to require Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css
您必须在 application.css 中要求 Bootstrap LESS (bootstrap_and_overrides.css.less)
/*
*= require bootstrap_and_overrides
*/
回答by Aghyad
I'm going to answer this noting that I am working on ruby 2 / rails 4 application (NOT rails 3)
我要回答这个问题,我正在研究 ruby 2 / rails 4 应用程序(不是 rails 3)
Requiring Bootstrap LESS (bootstrap_and_overrides.css.less) in your application.css is meaningless here, because the pipeline comes already with "require_tree ." which automatically includes everything inside the folders of the asset pipeline.
在 application.css 中要求 Bootstrap LESS (bootstrap_and_overrides.css.less) 在这里没有意义,因为管道已经带有“require_tree”。它会自动包含资产管道文件夹中的所有内容。
After pulling my hair for several hours, I found that removing the 3 required gems from the group :asset in the Gemfile is the only way to fix it
拉我的头发几个小时后,我发现从 Gemfile 中的组 :asset 中删除 3 个必需的宝石是修复它的唯一方法
So, Do Not do this in you Gemfile:
所以,不要在你的 Gemfile 中这样做:
group :assets do
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
end
And instead DO this:
而是这样做:
gem "therubyracer"
gem "less-rails"
gem "twitter-bootstrap-rails"
回答by superluminary
The Bootstrap gem comes with it's own bundled version of Bootstrap which it will take responsibility for importing. Don't import the Bootstrap gem in the :assets group, or the gem assets won't be found.
Bootstrap gem 带有它自己的 Bootstrap 捆绑版本,它将负责导入。不要在 :assets 组中导入 Bootstrap gem,否则将找不到 gem 资产。
Note that the assets group has been removed in Rails 4.
请注意,资产组已在 Rails 4 中删除。
回答by Peter Todd
I was using Bootstrap 2 and less on Rails 4.0.1. I decided to upgrade to Bootstrap 3 but "twitter-bootstrap-rails" is still on Bootstrap 2. There are a few gems available but I found the simplest approach was to add the css, js and fonts manually (followed these instructions Using bootstrap 3 with rails 4).
我在 Rails 4.0.1 上使用 Bootstrap 2 及以下版本。我决定升级到 Bootstrap 3,但“twitter-bootstrap-rails”仍在 Bootstrap 2 上。有一些 gems 可用,但我发现最简单的方法是手动添加 css、js 和字体(按照这些说明使用 bootstrap 3带导轨 4)。
Follow these instructions, ensure "therubyracer" and "less-rails" gems are installed and then a few more steps are required to get less working with bootstrap 3 and rails 4:
按照这些说明,确保安装了“therubyracer”和“less-rails” gems,然后需要更多的步骤来减少引导程序 3 和 rails 4 的工作:
- Download Bootstrap 3 source (Bootstrap source)
- Create directory "/vendor/assets/stylesheets/bootstrap"
- Copy contents of bootstrap source "less" directory (lots of less files) to "/vendor/assets/stylesheets/bootstrap"
Create "bootstrap_and_override.css.less" in "app/assets/stylesheets". Import "bootstrap.less" into "bootstrap_and_override.css.less", example of mine including a couple of test customisations:
@import "../../../vendor/assets/stylesheets/bootstrap/bootstrap.less"; @navbar-height: 120px; @body-bg: #F7911B;
- 下载 Bootstrap 3 源代码(Bootstrap 源代码)
- 创建目录“/vendor/assets/stylesheets/bootstrap”
- 将引导源“less”目录(大量文件)的内容复制到“/vendor/assets/stylesheets/bootstrap”
在“app/assets/stylesheets”中创建“bootstrap_and_override.css.less”。将“bootstrap.less”导入“bootstrap_and_override.css.less”,我的例子包括几个测试定制:
@import "../../../vendor/assets/stylesheets/bootstrap/bootstrap.less"; @navbar-height: 120px; @body-bg: #F7911B;
Hope this is useful to anyone wanting to try Bootstrap 3 with less.
希望这对任何想要以更少的价格尝试 Bootstrap 3 的人有用。
回答by Sachin Singh
for me, less-railsgem was missing from Gemfile and adding it and running bundlesolved the issue.
对我来说,less-railsGemfile 中缺少 gem 并添加它并运行bundle解决了这个问题。
回答by chanakya devraj
You might have missed to run
rails g bootstrap:install less
It worked like a charm
你可能错过了运行
rails g bootstrap:install less
它就像一个魅力

