未定义的方法“有吗?” for Sass :: Util:Module(NoMethodError)-Debian在使用Ruby,Sass,Compass时出错

时间:2019-02-08 20:04:06

标签: ruby linux sass compass nomethoderror

我搜索了以下问题的解决方案,但找不到任何东西。所以我希望你能帮助我。谢谢。

我有:

  • Debian Stretch (发行版:Debian GNU/Linux 9.7,内核:Linux 4.9.0-8-amd64 (x86_64));
  • Apache NetBeans 10(正在孵化)-从https://snapcraft.io/netbeans安装的快照;
  • PHP 7.1


我安装了(通过从this页上启发自己:

  • Ruby (使用:sudo apt install ruby-full);
  • 无礼(带有sudo gem install sass);
  • 指南针(带有sudo gem install compass);

并检查其版本:

# ruby --version
ruby 2.3.3p222 (2016-11-21) [x86_64-linux-gnu]

# sass --version
Ruby Sass 3.7.3

# compass --version
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2019 Chris Eppstein

请注意,我对Ruby没有任何经验。


我有以下 NetBeans设置

*)在选项卡“工具>选项> HTML / JS> CSS预处理器”

Sass Path: /usr/local/bin/sass

我也尝试过:

Sass Path: /usr/local/bin/scss

*)在选项卡“文件>项目属性> CSS预处理器> Sass”中

Input: /web/src/Application/assets/scss
Output: /web/public/assets/css
Compiler Options: --compass -E "UTF-8" --trace --no-cache


回溯:

当我尝试编译 .scss 文件(以创建相应的 .css 文件)时,我收到了每个文件的错误。这是第一个 .scss 文件的回溯记录:

"/usr/local/bin/sass" "--cache-location" "/home/<my-username>/snap/netbeans/common/cache/10.0/sass-compiler" "--sourcemap=none" "--compass" "-E" "UTF-8" "--trace" "--no-cache" "<my-path-to-project-root>/web/src/Application/assets/scss/fonts.scss" "<my-path-to-project-root>/web/public/assets/css/fonts.css"
/var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions/urls.rb:5:in `has?': undefined method `has?' for Sass::Util:Module (NoMethodError)
Did you mean?  hash
               Hash
    from /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions/urls.rb:9:in `included'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/script/functions.rb:627:in `include'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/script/functions.rb:627:in `include'
    from /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions.rb:23:in `<module:Functions>'
    from /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions.rb:19:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions.rb:9:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core.rb:68:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require'
    from /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass.rb:14:in `block in <top (required)>'
    from /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass.rb:13:in `each'
    from /var/lib/gems/2.3.0/gems/compass-1.0.3/lib/compass.rb:13:in `<top (required)>'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:127:in `rescue in require'
    from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/exec/sass_scss.rb:238:in `load_compass'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/exec/sass_scss.rb:49:in `process_result'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/exec/base.rb:50:in `parse'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/lib/sass/exec/base.rb:18:in `parse!'
    from /var/lib/gems/2.3.0/gems/sass-3.7.3/bin/sass:13:in `<top (required)>'
    from /usr/local/bin/sass:22:in `load'
    from /usr/local/bin/sass:22:in `<main>'
Done.


urls.rb 文件

这是在backtrace中指定的文件的开始内容( /var/lib/gems/2.3.0/gems/compass-core-1.0.3/lib/compass/core/sass_extensions/functions/ urls.rb ):

module Compass::Core::SassExtensions::Functions::Urls


  def self.has?(base, instance_method)
    Sass::Util.has?(:instance_method, base, instance_method)
  end

  def self.included(base)
    base.send(:include, StylesheetUrl) unless has?(base, :stylesheet_url)
    base.send(:include, FontUrl) unless has?(base, :font_url)
    base.send(:include, ImageUrl) unless has?(base, :image_url)
    base.send(:include, GeneratedImageUrl) unless has?(base, :generated_image_url)
  end

2 个答案:

答案 0 :(得分:2)

找到此搜索相同的错误消息。通过将本地的sass版本从df[!duplicated(data.table::rleid(df$var3)), ] 切换到sass-3.7.4,我可以解决此问题。

此错误消息的另一种可能的修复方法。

答案 1 :(得分:0)

问题:

问题出在以下事实上:我安装了Debian的软件包ruby-full以及Sass和Compass作为红宝石,例如使用 gem 命令行工具。

解决方案:

默认情况下,Debian 9.7( Stretch )已安装Ruby解释器(2.3版)。程序包名称为ruby2.3。为了能够正确编译.scss文件并使用Compass提供的功能,必须另外安装软件包ruby-sassruby-compass

遵循的步骤:

I)首先,使用终端,我卸载了以前错误安装的库:

我卸载了软件包ruby-full

$ sudo apt purge ruby-full
$ sudo apt autoremove

我卸载了Sass和Compass宝石:

$ sudo gem uninstall compass
$ sudo apt autoremove

$ sudo gem uninstall sass
$ sudo apt autoremove

II)然后我继续安装新软件包:

我检查了Debian的默认Ruby版本的状态:

$ apt list ruby2.3*
ruby2.3/stable,now 2.3.3-1+deb9u4 amd64 [installed]
ruby2.3-dev/stable,now 2.3.3-1+deb9u4 amd64 [installed,automatic]
ruby2.3-doc/stable,now 2.3.3-1+deb9u4 all [installed,automatic]

我安装了新软件包:

$ apt update
$ apt install ruby-sass
$ apt install ruby-compass

我检查了两个已安装软件包的版本:

$ sass --version
Sass 3.4.23 (Selective Steve)

$ compass --version
Compass 1.0.3 (Polaris)
Copyright (c) 2008-2019 Chris Eppstein

我检查了已安装的可执行文件的位置:

$ which sass
/usr/bin/sass

$ which compass
/usr/bin/compass

III)最后,在Netbeans的标签Tools > Options > HTML/JS > CSS Preprocessors中,将Sass Path设置为/usr/bin/sass

就是这样。正确编译了Sass文件,并正确识别和调用了Compass函数。