要导入的文件未找到或不可读:指南针

时间:2013-03-19 22:39:09

标签: sass compass-sass

我成功安装了Sass,但是我无法导入Compass。

以下是错误详情:

*Syntax error: File to import not found or unreadable: compass.
              Load path: H:/HTML/___keoFull/sass
.....
Backtrace:
mainKeo.scss:2
style.scss:2
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/import_node.rb:67:in `rescue in import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/import_node.rb:45:in `import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/import_node.rb:28:in `imported_file'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/import_node.rb:37:in `css_import?'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:217:in `visit_import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:37:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:100:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:227:in `block in visit_import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:227:in `map'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:227:in `visit_import'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:37:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:100:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:53:in `block in visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:53:in `map'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:53:in `visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:109:in `block in visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:121:in `with_environment'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:108:in `visit_children'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:37:in `block in visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:128:in `visit_root'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/base.rb:37:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:100:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/visitors/perform.rb:7:in `visit'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/tree/root_node.rb:20:in `render'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/engine.rb:315:in `_render'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/engine.rb:262:in `render'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin/compiler.rb:341:in `update_stylesheet'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin/compiler.rb:203:in `block in update_stylesheets'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin/compiler.rb:201:in `each'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin/compiler.rb:201:in `update_stylesheets'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin/compiler.rb:235:in `watch'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/plugin.rb:107:in `method_missing'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/exec.rb:444:in `watch_or_update'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/exec.rb:307:in `process_result'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/exec.rb:41:in `parse'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/lib/sass/exec.rb:21:in `parse!'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/sass-3.2.6/bin/sass:9:in `<top (required)>'*

5 个答案:

答案 0 :(得分:116)

指南针调整部分导入的方式。它允许仅根据名称导入组件,而无需指定路径。

@import 'compass';之前,你应该:

将Compass安装为Ruby gem:

gem install compass

之后,您应该使用Compass自己的命令行工具来编译您的SASS代码:

cd path/to/your/project/
compass compile

请注意,Compass会重新启动名为config.rb的配置文件。您应该为Compass创建它。

最小config.rb可以像这样简单:

css_dir =   "css"
sass_dir =  "sass"

您的SASS代码应位于sass/

您可以使用compass create <project-name>创建一个空的Compass项目,然后将SASS代码复制到其中,而不是手动创建配置文件。

请注意,如果您想使用Compass扩展程序,则必须:

  1. config.rb;
  2. 中要求他们
  3. 从您的SASS文件中导入它们。
  4. 此处有更多信息:http://compass-style.org/help/

答案 1 :(得分:16)

我使用Rails 4.0.2和compass-rails 1.1.3

看到了这个问题

我在gem 'compass-rails'

中将:assets组移到Gemfile组之外,从而解决了这个错误

它看起来像这样:

# stuff
gem 'compass-rails', '~> 1.1.3'
group :assets do
  # more stuff
end

答案 2 :(得分:3)

我卸载指南针1.0.1并安装指南针0.12.7,这个修复问题对我来说

$ sudo gem uninstall compass
$ sudo gem install compass -v 0.12.7

答案 3 :(得分:3)

如果你像我一样来到这里寻找一种方法来制作sass - 使用指南针工作,答案是使用指南针&#39;手表的版本,简单地说:

compass watch

如果您使用的是Mac并且尚未安装gem,则在尝试安装Compass gem时可能会遇到错误,原因是OSX版本10.11之后出现权限问题。用Homebrew安装ruby以解决这个问题。见this answer for how to do that.

或者你可以使用CodeKit,但如果你像我一样顽固并且想要使用Sublime Text和命令行,那么这就是要走的路。

答案 4 :(得分:2)

简而言之,如果你已经安装了gem:

compass compile

在你的rails根目录