尝试让Sass观看目录时出现Ruby语法错误

时间:2017-07-15 18:04:57

标签: ruby sass

所以我刚刚开始使用Sass,到目前为止我已经更新了我的Ruby安装,安装了Sass并创建了两个练习目录和一个.scss文件。但当我到达告诉sass同时观看我的scss和css目录的步骤时,我在命令提示符中得到了大量的错误:

C:\sasstest>sass --watch scss:css
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2054:
 warning: else without rescue is useless
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2060:
 warning: else without rescue is useless
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2099:
 warning: else without rescue is useless
C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `re
quire': C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.
rb:2050: syntax error, unexpected modifier_if (SyntaxError)
          if separator.value == 'auto'
            ^
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2054:
 syntax error, unexpected ',', expecting keyword_end
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2060:
 syntax error, unexpected ')', expecting keyword_end
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2095:
 syntax error, unexpected modifier_if
          if separator.value == 'auto'
            ^
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2099:
 syntax error, unexpected ')', expecting keyword_end
C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script/functions.rb:2885:
 syntax error, unexpected keyword_end, expecting end-of-input
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script.rb:34
:in `<module:Script>'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script.rb:8:
in `<module:Sass>'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/script.rb:3:
in `<top (required)>'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass/engine.rb:47
:in `<top (required)>'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/lib/sass.rb:99:in `<t
op (required)>'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require
.rb:55:in `require'
        from C:/Ruby21/lib/ruby/gems/2.1.0/gems/sass-3.5.1/bin/sass:6:in `<top (
required)>'
        from C:/Ruby21/bin/sass:23:in `load'
        from C:/Ruby21/bin/sass:23:in `<main>'

C:\sasstest>

我应该注意,即使直接观看这两个文件也会得到相同的结果。有什么建议吗?

我目前的Ruby btw版本是:2.6.12

1 个答案:

答案 0 :(得分:0)

你不能拥有ruby 2.6.12 ,因为最新版本是 2.4.2 ruby releases)。要运行ruby版本

ruby -version 

在终端。您很可能拥有 2.1.0

2.6.12 是RubyGems的版本 - 检查它是否运行

gem --version

你遇到的问题看起来像是saas和ruby版本的不兼容 - 根据这个issue,saas 3.5.1与 2.1.3 下的ruby版本不兼容。所以你需要更新ruby版本。