【问题标题】:Error on installing Visual Ruby on OSX在 OSX 上安装 Visual Ruby 时出错
【发布时间】:2012-10-13 10:56:57
【问题描述】:

我正在尝试在 OSX 上安装 Visual Ruby。按照 VisualRuby.net 上的指南,我做了以下事情。

brew install gtk+

然后:

brew install gtksourceview

最后:

sudo gem install visualruby

这会产生以下错误消息。我不知道出了什么问题,有什么想法吗?

Building native extensions.  This could take a while...
ERROR:  Error installing visualruby:
    ERROR: Failed to build gem native extension.

        /Users/ma/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb
checking for -Wall option to compiler... yes
checking for -Waggregate-return option to compiler... yes
checking for -Wcast-align option to compiler... yes
checking for -Wextra option to compiler... yes
checking for -Wformat=2 option to compiler... yes
checking for -Winit-self option to compiler... yes
checking for -Wlarger-than-65500 option to compiler... yes
checking for -Wmissing-declarations option to compiler... yes
checking for -Wmissing-format-attribute option to compiler... yes
checking for -Wmissing-include-dirs option to compiler... yes
checking for -Wmissing-noreturn option to compiler... yes
checking for -Wmissing-prototypes option to compiler... yes
checking for -Wnested-externs option to compiler... yes
checking for -Wold-style-definition option to compiler... yes
checking for -Wpacked option to compiler... yes
checking for -Wp,-D_FORTIFY_SOURCE=2 option to compiler... yes
checking for -Wpointer-arith option to compiler... yes
checking for -Wswitch-default option to compiler... yes
checking for -Wswitch-enum option to compiler... yes
checking for -Wundef option to compiler... yes
checking for -Wunsafe-loop-optimizations option to compiler... yes
checking for -Wwrite-strings option to compiler... yes
checking for rb_define_alloc_func() in ruby.h... yes
checking for rb_block_proc() in ruby.h... yes
checking for new allocation framework... yes
checking for attribute assignment... no
checking for cairo... yes
checking for rb_cairo.h... yes
checking for Win32 OS... no
checking for gtksourceview-2.0... yes
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --without-make-prog
    --srcdir=.
    --curdir
    --ruby=/Users/ma/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
    --with-pkg-config
    --without-pkg-config
    --with-override-variables
    --without-override-variables
/Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:239:in `parse_pc': .pc for libxml-2.0 doesn't exist. (RuntimeError)
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:181:in `declaration'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:130:in `requires_private'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:311:in `all_required_packages'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:195:in `collect_cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:134:in `cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:196:in `block in collect_cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:195:in `collect'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:195:in `collect_cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:134:in `cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:364:in `cflags'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/pkg-config-1.1.4/lib/pkg-config.rb:415:in `have_package'
    from /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/glib2-1.1.5/lib/mkmf-gnome2.rb:540:in `required_pkg_config_package'
    from extconf.rb:58:in `<main>'


Gem files will remain installed in /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/gtksourceview2-1.1.5 for inspection.
Results logged to /Users/ma/.rvm/gems/ruby-1.9.3-p194/gems/gtksourceview2-1.1.5/ext/gtksourceview2/gem_make.out

【问题讨论】:

    标签: ruby macos gtk homebrew


    【解决方案1】:

    试试brew update 如果你正在跑山狮,你可能会遇到这个bug

    【讨论】:

      【解决方案2】:

      我遇到了同样的问题。我发现山狮在/usr/lib/pkgconfig 中缺少libxml-2.0.pc 文件,如here 所述。

      确保libxml2 已安装后:

      brew install libxml2
      

      我创建了允许我安装 VisualRuby 的建议符号链接。

      sudo ln -s /usr/local/Cellar/libxml2/2.9.0/lib/pkgconfig/libxml-2.0.pc /usr/lib/pkgconfig
      

      【讨论】:

      • 这行得通。我不得不将版本号从 2.9.0 提高到 2.9.1 虽然:sudo ln -s /usr/local/Cellar/libxml2/2.9.1/lib/pkgconfig/libxml-2.0.pc /usr/lib/pkgconfig
      • 我遇到了类似的问题,虽然我必须将 libpng16.pc 实际复制到 /usr/lib/pkgconfig。
      • 谢谢 - 涉及 gobject-introspection 在 mac osx 上安装的单独问题,但类似的 simlink 有帮助
      【解决方案3】:

      我在 El Capitan 上安装时遇到了这个问题。我无法使用建议的解决方案来创建链接,操作系统阻止了任何更改。我用过

      brew link libxml2 --force
      

      这修复了链接并解决了问题

      【讨论】: