Ruby 指南针/SASS喷灯问题:Can';不读文件?

Ruby 指南针/SASS喷灯问题:Can';不读文件?,ruby,sprite,compass-sass,sass,Ruby,Sprite,Compass Sass,Sass,这是我的SCSS: @import "compass"; $spriteretina: sprite-map("sprite-retina/*.png"); $sprite: sprite-map("sprite/*.png"); @mixin retina-sprite($name) { background-image: sprite-url($sprite); background-position: sprite-position($sprite, $name);

这是我的SCSS:

@import "compass";

$spriteretina: sprite-map("sprite-retina/*.png");
$sprite: sprite-map("sprite/*.png");  

@mixin retina-sprite($name) {
    background-image: sprite-url($sprite);
    background-position: sprite-position($sprite, $name);
    background-repeat: no-repeat;
    display: block;
    height: image-height(sprite-file($sprite, $name));
    width: image-width(sprite-file($sprite, $name));
    @media (-webkit-min-device-pixel-ratio: 2), (-o-min-device-pixel-ratio: 3/2), (min-device-pixel-ratio: 2) {
        // Workaround for https://gist.github.com/2140082
        @if (sprite-position($sprite, $name) != sprite-position($spriteretina, $name)) {
            $ypos: round(nth(sprite-position($spriteretina, $name), 2) / 2);
            background-position: 0 $ypos;
        }
        // Set image size to the orginal size of the image
        @include background-size(ceil(image-width(sprite-path($spriteretina)) / 2) auto);
        background-image: sprite-url($spriteretina);
    }
}

.logo {
    background-image: sprite-url($spriteretina);
}
当我尝试编译时,出现以下错误:

PS C:\part\to\Website> compass compile
unchanged Frontend/img/icons-s49ccc64d2b.png
unchanged Frontend/img/sprite-s8e1b03f13e.png
Errno::ENOENT on line 28 of C: No such file or directory - Frontend/img/sprite-retina-sdc5ec023dc.png
Run with --trace to see the full backtrace
我以完全回溯的方式运行它,得到以下结果:

Errno::ENOENT on line 28 of C: No such file or directory - Frontend/img/sprite-retina-s7f5af5584d.png
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:28:in `open'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:28:in `get_size_for_png'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:21:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:21:in `size'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:50:in `image_dimensions'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/sass_extensions/functions/image_size.rb:4:in `image_width'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:106:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:106:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/operation.rb:74:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/funcall.rb:93:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/list.rb:70:in `_perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/script/node.rb:40:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:257:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:362:in `visit_media'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:266:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:68:in `perform_arguments'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:261:in `visit_mixin'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:318:in `visit_rule'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:318:in `visit_rule'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `visit_import'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:225:in `visit_import'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `map'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:53:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:107:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:119:in `with_environment'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:106:in `visit_children'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:126:in `visit_root'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/base.rb:37:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:98:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:7:in `send'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/visitors/perform.rb:7:in `visit'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/tree/root_node.rb:20:in `render'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/engine.rb:315:in `_render'
  C:/ruby187/lib/ruby/gems/1.8/gems/sass-3.2.2/lib/sass/../sass/engine.rb:262:in `render'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:140:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:139:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/logger.rb:45:in `red'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:138:in `compile'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:118:in `compile_if_required'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:103:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `each'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:101:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:126:in `timed'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/compiler.rb:100:in `run'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/update_project.rb:45:in `perform'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/base.rb:18:in `execute'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/commands/project_base.rb:19:in `execute'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:43:in `perform!'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/lib/compass/exec/sub_command_ui.rb:15:in `run!'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:30
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:44:in `call'
  C:/ruby187/lib/ruby/gems/1.8/gems/compass-0.12.2/bin/compass:44
  C:/ruby187/bin/compass:19:in `load'
  C:/ruby187/bin/compass:19
对我来说,它似乎是试图在创建sprite文件之前读取它。这是一个错误。但是为什么我会经历这种行为呢?我能做些什么来修复它


我试图删除所有.sass缓存文件,重命名了我的文件夹。但是运气不好。

我通过一个变通办法解决了这个问题。这很简单,只需在使用精灵的mixin之前创建一个选择器,如下所示:

.fixesabugwithcompass {
    background-image: sprite-url($sprite-retina-sprites);
}
每次在mixin中使用指南针生成图像时,仍然存在一个问题。据此间报道:

我通过一个变通办法解决了这个问题。这很简单,只需在使用精灵的mixin之前创建一个选择器,如下所示:

.fixesabugwithcompass {
    background-image: sprite-url($sprite-retina-sprites);
}
每次在mixin中使用指南针生成图像时,仍然存在一个问题。据此间报道: