Windows 上的 Sass(Ruby CSS 压缩器)绝对路径参数

发布于 2024-09-14 01:49:54 字数 2156 浏览 16 评论 0原文

我正在使用 sass (来自 haml-edge)进行处理css 文件,并且它在作为参数的绝对路径上崩溃:

K:\sass>sass.bat k:/sass/css/*.scss k:/sass/css/*.css --trace
d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/files.rb:23:in `read': No such file or directory - k
 (Errno::ENOENT)
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/files.rb:23:in `tree_for'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:220:in `update_stylesheet'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `block in update_stylesheets'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `each'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `update_stylesheets'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:433:in `watch_or_update'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:349:in `process_result'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:41:in `parse'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:21:in `parse!'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/bin/sass:8:in `<top (required)>'
    from d:/Programs/Ruby/bin/sass:19:in `load'
    from d:/Programs/Ruby/bin/sass:19:in `<main>'

我可以通过在 split_colon_path (Ruby\lib\ruby\gems\1.9.1) 中注释一个条件来使其工作。 1\gems\haml-edge-3.1.62\lib\haml\exec.rb):

def split_colon_path(path)
  one, two = path.split(':', 2)
  if one && two && #### this part was commented #  ::Haml::Util.windows? &&
      one =~ /\A[A-Za-z]\Z/ && two =~ /\A[\/\\]/
    # If we're on Windows and we were passed a drive letter path,
    # don't split on that colon.
    one2, two = two.split(':', 2)
    one = one + ':' + one2
  end
  return one, two
end

是否有更好的平台检测解决方案?

I'm using sass (from haml-edge) for processing css files, and it crashes on absolute paths as parameters:

K:\sass>sass.bat k:/sass/css/*.scss k:/sass/css/*.css --trace
d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/files.rb:23:in `read': No such file or directory - k
 (Errno::ENOENT)
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/files.rb:23:in `tree_for'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:220:in `update_stylesheet'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `block in update_stylesheets'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `each'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/sass/plugin.rb:71:in `update_stylesheets'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:433:in `watch_or_update'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:349:in `process_result'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:41:in `parse'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/lib/haml/exec.rb:21:in `parse!'
    from d:/Programs/Ruby/lib/ruby/gems/1.9.1/gems/haml-edge-3.1.62/bin/sass:8:in `<top (required)>'
    from d:/Programs/Ruby/bin/sass:19:in `load'
    from d:/Programs/Ruby/bin/sass:19:in `<main>'

I was able to make it work by commenting one condition in split_colon_path (Ruby\lib\ruby\gems\1.9.1\gems\haml-edge-3.1.62\lib\haml\exec.rb):

def split_colon_path(path)
  one, two = path.split(':', 2)
  if one && two && #### this part was commented #  ::Haml::Util.windows? &&
      one =~ /\A[A-Za-z]\Z/ && two =~ /\A[\/\\]/
    # If we're on Windows and we were passed a drive letter path,
    # don't split on that colon.
    one2, two = two.split(':', 2)
    one = one + ':' + one2
  end
  return one, two
end

Is there a better solution for platform detection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄荷港 2024-09-21 01:49:54

这是一个已知的错误。它已在 Sass 的最新稳定版本中修复,除非您使用 mingw Ruby,在这种情况下,它将在下一个稳定版本(本周末发布)中修复。

This is a known bug. It's fixed in the latest stable version of Sass, unless you're using mingw Ruby, in which case it'll be fixed in the next stable version (to be released this weekend).

风透绣罗衣 2024-09-21 01:49:54

问题已在 haml-edge 3.1.64 中解决。

作为记录,mingw 已添加到 {Ruby 文件夹}\lib\ruby\gems\1.9.1\gems\haml-edge 中的 host_os 可能值-3.1.64\lib\haml\util.rb

# Whether or not this is running on Windows.
#
# @return [Boolean]
def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
end

Problem solved in haml-edge 3.1.64.

For the record, mingw was added to the host_os possible values in {Ruby folder}\lib\ruby\gems\1.9.1\gems\haml-edge-3.1.64\lib\haml\util.rb:

# Whether or not this is running on Windows.
#
# @return [Boolean]
def windows?
  RbConfig::CONFIG['host_os'] =~ /mswin|windows|mingw/i
end
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文