所以我遇到了我的Rails项目的问题。在我的Gemfile中,这是我的代码:
source 'https://rubygems.org'
gem 'rails', '4.0.3'
gem 'sqlite3'
gem 'thin'
gem 'uglifier', '>= 1.3.0'
group :assets do
gem 'sass-rails', '~> 4.0.1'
gem 'coffee-rails', '~> 4.0.0'
gem 'eco'
gem 'compass-rails'
gem 'bootstrap-sass'
end
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
group :doc do
gem 'sdoc', require: false
end
这是我的application.css.scss文件:
@import "bootstrap";
如果我选择'组,我会遇到此错误:资产包含'阻止,而只是尝试运行rails w / out:
/Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches/browser_support.rb:1:in `require': cannot load such file -- sass/script/node (LoadError)
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches/browser_support.rb:1:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:2:in `require'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:2:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:in `each'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions/monkey_patches.rb:1:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions.rb:9:in `require'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass/sass_extensions.rb:9:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass.rb:5:in `require'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass.rb:5:in `block in <top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass.rb:4:in `each'
from /Library/Ruby/Gems/2.0.0/gems/compass-0.12.2/lib/compass.rb:4:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/compass-rails-1.1.3/lib/compass-rails.rb:1:in `require'
from /Library/Ruby/Gems/2.0.0/gems/compass-rails-1.1.3/lib/compass-rails.rb:1:in `<top (required)>'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:72:in `block in require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `each'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler/runtime.rb:61:in `require'
from /Library/Ruby/Gems/2.0.0/gems/bundler-1.5.3/lib/bundler.rb:131:in `require'
from /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/config/application.rb:12:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/config/environment.rb:2:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in `require'
from /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/config.ru:3:in `block in <main>'
from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `instance_eval'
from /Library/Ruby/Gems/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:55:in `initialize'
from /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/config.ru:1:in `new'
from /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/config.ru:1:in `<main>'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/rack/adapter/loader.rb:33:in `eval'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/rack/adapter/loader.rb:33:in `load'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/rack/adapter/loader.rb:42:in `for'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/thin/controllers/controller.rb:170:in `load_adapter'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/thin/controllers/controller.rb:74:in `start'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/thin/runner.rb:199:in `run_command'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/lib/thin/runner.rb:155:in `run!'
from /Library/Ruby/Gems/2.0.0/gems/thin-1.6.2/bin/thin:6:in `<top (required)>'
from /usr/bin/thin:23:in `load'
from /usr/bin/thin:23:in `<main>'
要摆脱这种情况,我必须使用该组:资产会阻止。但是,一旦我启动并运行了rails服务器,如果&#39; @import&#34; bootstrap&#34 ;;&#39;在application.css.scss中(因为文件附加了.scss),当我尝试在浏览器中加载rails项目时出现以下错误:
Showing /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/app/views/layouts/application.html.erb where line #5 raised:
File to import not found or unreadable: bootstrap.
Load paths:
/Users/Stuart/Documents/Code/Sublime/one_kingdom_design/app/assets/images
/Users/Stuart/Documents/Code/Sublime/one_kingdom_design/app/assets/javascripts
/Users/Stuart/Documents/Code/Sublime/one_kingdom_design/app/assets/stylesheets
/Users/Stuart/Documents/Code/Sublime/one_kingdom_design/vendor/assets/javascripts
/Users/Stuart/Documents/Code/Sublime/one_kingdom_design/vendor/assets/stylesheets
/Library/Ruby/Gems/2.0.0/gems/turbolinks-2.2.1/lib/assets/javascripts
/Library/Ruby/Gems/2.0.0/gems/jquery-rails-3.1.0/vendor/assets/javascripts
(in /Users/Stuart/Documents/Code/Sublime/one_kingdom_design/app/assets/stylesheets/application.css.scss:13)
以下是它突出显示的提取源:
<html>
<head>
<title>OneKingdomDesign</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>//this line is highlighted in the firefox browser
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= csrf_meta_tags %>
</head>
任何人都可以帮我找到这个问题的根源吗?我相信它与Sass宝石有关,但我不确定。如果重要,我会使用Ruby 2.0.0p247。
编辑:我把它缩小了,它不是sass,它是指南针。无论我尝试什么,指南针都试图与我争辩。答案 0 :(得分:0)
我一直有类似的问题,我认为我已经到底了
首先,我可以解释为什么只有在gemfile中不包含资产组时才会收到错误。 Rails 4不期望在那里有资产组,也不包括宝石。这意味着如果您的basecamp gem包含在组中:资产确实阻止它不被包含在内,因此当您尝试使用@import包含它们时,预编译没有问题,也没有bootcamp文件。
现在为什么预编译出错了。我注意到了这里:
http://rubygems.org/gems/sass-rails
Sass-rails要求链轮小于或等于2.11.0,即它与版本2.11.1不兼容,这是我在捆绑中得到的。我认为这些东西应该由捆绑器自动处理,所以我不知道那里发生了什么。我建议你查看你的Gemfile.lock并检查你拥有的sass版本(sass-rails包含的版本)和bootstrap-sass以及所有各种依赖项,并确保rubygems同意它们是兼容的。
希望有所帮助。
答案 1 :(得分:0)
我在rails4 app中使用以下内容。
gem 'sass-rails', '~> 4.0.0'
gem 'bootstrap-sass'
答案 2 :(得分:0)
我遇到了类似的问题,但是从sass 4.0.1更新解决了它。
gem 'sass-rails', '4.0.3'