繁体   English   中英

在Ruby 2.0.0p353(基于rvm的安装)下安装Nokogiri 1.6.1失败(OSX Mavericks)?

[英]Install Nokogiri 1.6.1 under Ruby 2.0.0p353 (rvm based installation) fails (OSX Mavericks)?

我试图在Ruby和RVM下安装Nokogiri 1.6.1,但是失败了以下错误:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

/Users/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby extconf.rb 
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-apple-darwin13.0.0/ports/libxml2/2.8.0... OK
Running 'configure' for libxml2 2.8.0... OK
Running 'compile' for libxml2 2.8.0... OK
Running 'install' for libxml2 2.8.0... OK
Activating libxml2 2.8.0 (from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0)...
Extracting libxslt-1.1.26.tar.gz into tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26... OK
Running 'configure' for libxslt 1.1.26... ERROR, review 'tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26/configure.log' to see what happened.
*** 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/lmo0/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:265:in `block in execute': Failed to complete configure task (RuntimeError)
    from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `chdir'
    from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:257:in `execute'
    from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:65:in `configure'
    from /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/mini_portile-0.5.2/lib/mini_portile.rb:108:in `cook'
    from extconf.rb:101:in `block in <main>'
    from extconf.rb:131:in `call'
    from extconf.rb:131:in `block in <main>'
    from extconf.rb:122:in `tap'
    from extconf.rb:122:in `<main>'


Gem files will remain installed in /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1 for inspection.
Results logged to /Users/lmo0/.rvm/gems/ruby-2.0.0-p353/gems/nokogiri-1.6.1/ext/nokogiri/gem_make.out

检查您的grep版本并安装最新的brew brew:

$ grep --version
grep (BSD grep) 2.5.1-FreeBSD

$ brew install grep --default-names

# If above fails, you probably need to tap
$ brew tap homebrew/dupes
$ brew install grep --default-names

$ grep --version
grep (GNU grep) 2.14.56-1e3d

来自(这个nokogiri问题)[https://github.com/sparklemotion/nokogiri/issues/935]:“OSX的最新版本附带BSD grep,而较旧版本附带GNU grep。那么,你的构建脚本,也许需要GNU grep“

从Maverick的评论中被盗并在此复制作为答案,而不是评论,因为我现在已经多次遇到这个问题,并且希望能够让别人头疼。 = X

您可以尝试我到目前为止使用的解决方案来修复相同的...

删除所有旧的libxml-ruby和nokogiri

使用下面的命令

sudo gem uninstall nokogiri libxml-ruby

然后你可以尝试nokogiri的版本,有问题。 这应该是完美的。

sudo gem install nokogiri -v '1.6.1' 

Dan报告了许多类似的答案,但有些变化。 谢谢。

我自己处理后就写了这篇文章 不需要自制软件。

我遇到了一些问题,第一个问题是无法找到开发工具,第二个问题是libxml太旧了。

在rubyconsole中运行以下命令:

$ sudo xcode-select -switch /Library/Developer/CommandLineTools
$ gem uninstall nokogiri libxml-ruby
$ gem install nokogiri

原来有一个更简单的解决方案:

删除~/.bashrc~/.bash_profile文件中的这一行:

GREP_OPTIONS="--color=always"

这一个:

export GREP_OPTIONS="--color=auto"

这样您就不需要安装任何重复项。 感谢MrPowers @ Nokogiri问题

手动./configure'include'和'lib'位置帮助我。 libxml2源代码布局有点奇怪,所以我最终得到了类似的选项:

gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/usr/local/Cellar/libxml2/2.9.1/include/libxml2 --with-xml2-lib=/usr/local/Cellar/libxml2/2.9.1/lib

当然, 版本号取决于实际安装的内容 在写这篇文章的时候,那个版本正在酿造中。

在我的情况下/usr/local/Cellar/libxml2/2.9.1/include/libxml2包含一个名为libxml目录和/usr/local/Cellar/libxml2/2.9.1/lib包含libxml2.2.dylib libxml2.a libxml2.dylib pkgconfig xml2Conf.sh :这些是脚本正在寻找的,没有其他组合使它使用系统库进行编译。

使用homebrew nokogiri既可以安装既不过时也不兼容(最近的)libxml2和libxslt库,如本要点所述 为我工作得很好。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM