Gem sass 编码问题

metal · 2013年05月14日 · 最后由 luikore 回复于 2013年05月16日 · 5778 次阅读
Encoding::CompatibilityError: incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string)
/Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:193:in `sub': incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:193:in `relative_to_base'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:135:in `ignored?'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:328:in `block in important_paths'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:41:in `block in find'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:40:in `catch'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:40:in `find'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:322:in `important_paths'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/directory_record.rb:158:in `build'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/multi_listener.rb:41:in `block (2 levels) in start'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/multi_listener.rb:41:in `each'
    from /Users/Kenn/.rvm/gems/ruby-2.0.0-p0/gems/listen-0.7.3/lib/listen/multi_listener.rb:41:in `block in start'

不知道如何解决。求指点。

而且,这个 ruby 的版本也让我蛋疼不止。

 ruby -v
ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin12.3.0]

结果上面的 ruby gems 的目录默认是 ruby2.0,顺便求一下解决方法。

试试这个:

NOEXEC_DISABLE=1 sass
 NOEXEC_DISABLE=1 scss --watch --style compressed style.scss --trace

>>> Sass is watching for changes. Press Ctrl-C to stop.
/Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:193:in `sub': incompatible encoding regexp match (UTF-8 regexp with ASCII-8BIT string) (Encoding::CompatibilityError)
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:193:in `relative_to_base'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:135:in `ignored?'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:328:in `block in important_paths'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:41:in `block in find'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:40:in `catch'
    from /Users/Kenn/.rvm/rubies/ruby-1.9.3-p392/lib/ruby/1.9.1/find.rb:40:in `find'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:322:in `important_paths'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/directory_record.rb:158:in `build'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/multi_listener.rb:41:in `block (2 levels) in start'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/multi_listener.rb:41:in `each'
    from /Users/Kenn/.rvm/gems/ruby-1.9.3-p392/gems/sass-3.2.9/vendor/listen/lib/listen/multi_listener.rb:41:in `block in start'

依然无用。我之前一切正常,突然就这样

google 一下“UTF-8 regexp with ASCII-8BIT string”

我之前遇到过类似问题

gem 目录问题往往是 rubygems-bundler 整的 ruby_noexec_wrapper 搞出来的,改下环境变量就可以了。

sass 用的 listen 很旧了,没找到才 fallback 到 vendor 里去的,可能就是造成编码不合的原因。你加个新的 listen gem 试试?

#5 楼 @luikore GEMS_PATH 问题我解决了。 sass 这个 gem 我始终搞不定,我从 3.2.9 一直向下安装,sass 3.1.x 才没有问题。

专门跑去了看了 Sass Changelog, 3.2.9 也是最近才更新,应该不是 listen 太旧的问题。

3.2.9

  • Fix a bug where @extends would occasionally cause a selector to be generated with the incorrect specificity.
  • Avoid loading listen v1.0, even if it’s installed as a Gem (see issue 719).
  • Update the bundled version of listen to 0.7.3.
  • Automatically avoid the IE7 content: counter bug.

listen gem 这个出错的方法我改了下,刚发了 1.1.2 , 用新的 listen 不知道还有问题不?

需要 登录 后方可回复, 如果你还没有账号请 注册新账号