Ruby on rails Rails 3应用程序中的Sass导入错误-“;要导入的文件找不到或不可读:compass";

Ruby on rails Rails 3应用程序中的Sass导入错误-“;要导入的文件找不到或不可读:compass";,ruby-on-rails,ruby-on-rails-3,sass,compass-sass,blueprint-css,Ruby On Rails,Ruby On Rails 3,Sass,Compass Sass,Blueprint Css,我有一个Rails 3应用程序,在该应用程序上我成功运行了compass init Rails./--使用blueprint。我可以从/stylesheets目录@导入文件,但在尝试@导入compass时出错 目前,该应用程序有两个简单的sass文件: common.scss $body-background: blue; @import "common"; //@import "compass"; body { background: $body-background; } ma

我有一个Rails 3应用程序,在该应用程序上我成功运行了compass init Rails./--使用blueprint。我可以从/stylesheets目录
@导入
文件,但在尝试
@导入compass
时出错

目前,该应用程序有两个简单的sass文件:

common.scss

$body-background: blue;
@import "common";
//@import "compass";

body { 
  background: $body-background; 
}
main.scss

$body-background: blue;
@import "common";
//@import "compass";

body { 
  background: $body-background; 
}
注释掉了import“compass”行后,这就行了——我得到了一个蓝色背景,所以我知道Sass正在工作

如果我取消对该行的注释,并尝试导入
compass
blueprint
或任何其他内容,则会出现如下错误

Syntax error: File to import not found or unreadable: compass.
              Load paths:

                /Users/eric/path/to/myrailsapp/app/stylesheets
        on line 2 of /Users/eric/path/to/myrailsapp/app/stylesheets/main.scss

1: @import "common";
2: @import "compass";
3: 
4: body { 
5:  background: $body-background; 
6: }
也许我必须明确告诉Sass哪里可以找到指南针宝石,所以我在config/Compass.rb中添加了一个
add\u import\u path
行:

require 'compass'
require 'html5-boilerplate'

project_type = :rails
project_path = RAILS_ROOT if defined?(RAILS_ROOT)
add_import_path "/Library/Ruby/Gems/1.8/gems/"  # unfortunately this has no effect

http_path = "/"
css_dir = "public/stylesheets"
sass_dir = "app/stylesheets"
images_dir = "public/images"
javascripts_dir = "public/javascripts"
cache_dir = "tmp/sass-cache"

http_images_path = "/images"
http_stylesheets_path = "/stylesheets"
http_javascripts_path = "/javascripts"

我已经在谷歌上搜索了两天,无法确定为什么我的基本
@import
语句会出现这种问题。如何告诉Sass哪里可以找到指南针和蓝图库?

Sass中的@import命令导入.scss或.Sass文件,而不是.css文件

安装过程中似乎遗漏了什么。(可能是线路
指南针安装蓝图
?)我按照以下步骤操作:

无法重现问题。

好的,在克里斯·埃普斯坦的帮助下,我找到了令人不快的线索。在
config/environments.rb
中,我有一行:

Sass::Plugin.options[:template_location] = {
"#{RAILS_ROOT}/app/stylesheets" => "#{RAILS_ROOT}/public/stylesheets"
}

对于Rails(我有3.0.7)和Compass(0.11.1)的当前版本,这条线是不必要的。我在完成一个教程后添加了它。如果sass找不到compass,可能是因为这行代码弄乱了您的
sass::Plugin.options[:template\u location]

我遇到了这个错误

我将application.rb中的这一行从:

Bundler.require(:default, Rails.env) if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)
致:

另外,确保文件名为something.css.sass而不是something.sass

$body-background: blue;
@import "common";
//@import "compass";

body { 
  background: $body-background; 
}

还有一件事,我的配置目录中有一个旧的compass.rb文件,Rails 3.2不需要它。删除它也为我解决了这个问题。

我通过切换到
指南针导轨
gem而不是我的gem文件中的
指南针
gem解决了这个问题(别忘了重新启动服务器)。以防有人在这里遇到。

我在Rails 3.2.0服务器上解决了这个问题,方法是从
gem'compass Rails',“~>1.0.1'
中的
:Gemfile
组中的一个提示中移出
gem'compass Rails'。

我在头撞到它之后修复了这个错误

我在application.rb中对这一行进行了注释,其来源为:

Bundler.require(:default, Rails.env) if defined?(Bundler)
Bundler.require(*Rails.groups(:assets => %w(development test))) if defined?(Bundler)
和未注释的:

Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)    

我正在使用Rails 3.2.11

我修复了以下错误:

在application.rb中,我

Bundler.require(:default, Rails.env) if defined?(Bundler)  
改成

Bundler.require(:default, :assets, Rails.env) if defined?(Bundler)

这是在将一个项目从3.0.3更新到3.2.13之后完成的,我正在尝试包括常规compass and blueprint(scss)文件。安装蓝图上方的“compass init”行。为了确认我再次运行了该命令,您可以在下面的输出中看到compass认为所有东西都已安装。$compass install blueprint Identified app/stylesheets/screen.scss Identified app/stylesheets/partials/_base.scss Identified app/stylesheets/print.scss Identified app/stylesheets/ie.scss Identified public/images/grid.pngI创建了一个新的Rails 3.2.8项目今天开始,问题出在
compass.rb
上。我没有在
application.rb中更改任何内容。因此,首先删除
compass.rb
。这在Rails 3.2.13和compass Rails 1.0.3上对我不起作用。如果您添加了一个新环境,添加到
%w(开发测试)
,例如
%w(开发测试新环境名称)
应该足以让资产加载。