Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Nokogiri未能生成gem本机扩展(运行时错误)?_Ruby On Rails_Ruby_Rubygems_Gem_Nokogiri - Fatal编程技术网

Ruby on rails Nokogiri未能生成gem本机扩展(运行时错误)?

Ruby on rails Nokogiri未能生成gem本机扩展(运行时错误)?,ruby-on-rails,ruby,rubygems,gem,nokogiri,Ruby On Rails,Ruby,Rubygems,Gem,Nokogiri,我正在尝试使用以下方式安装Nokogiri: sudo gem install nokogiri 这是安装后的混乱情况: Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /Users/micahsherman/.rvm/rubies/ruby-1.9.

我正在尝试使用以下方式安装Nokogiri:

sudo gem install nokogiri
这是安装后的混乱情况:

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

        /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/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/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/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... OK
Running 'compile' for libxslt 1.1.26... OK
Running 'install' for libxslt 1.1.26... OK
Activating libxslt 1.1.26 (from /Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26)...
checking for libxml/parser.h... *** 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/micahsherman/.rvm/rubies/ruby-1.9.3-p429/bin/ruby
  --with-zlib-dir
  --without-zlib-dir
  --with-zlib-include
  --without-zlib-include=${zlib-dir}/include
  --with-zlib-lib
  --without-zlib-lib=${zlib-dir}/lib
  --with-iconv-dir
  --without-iconv-dir
  --with-iconv-include
  --without-iconv-include=${iconv-dir}/include
  --with-iconv-lib
  --without-iconv-lib=${iconv-dir}/lib
  --with-xml2-dir
  --without-xml2-dir
  --with-xml2-include
  --without-xml2-include=${xml2-dir}/include
  --with-xml2-lib
  --without-xml2-lib=${xml2-dir}/lib
  --with-xslt-dir
  --without-xslt-dir
  --with-xslt-include
  --without-xslt-include=${xslt-dir}/include
  --with-xslt-lib
  --without-xslt-lib=${xslt-dir}/lib
  --with-libxslt-config
  --without-libxslt-config
  --with-pkg-config
  --without-pkg-config
  --with-libxml-2.0-config
  --without-libxml-2.0-config
  --with-libiconv-config
  --without-libiconv-config
/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:in `try_do': The compiler failed to generate an executable file. (RuntimeError)
You have to install development tools first.
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in `open'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in `postpone'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for'
  from /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:969:in `find_header'
  from extconf.rb:166:in `<main>'


Gem files will remain installed in /Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0 for inspection.
Results logged to /Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
构建本机扩展。这可能需要一段时间。。。
错误:安装nokogiri时出错:
错误:无法生成gem本机扩展。
/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/bin/ruby-extconf.rb
正在将libxml2-2.8.0.tar.gz提取到tmp/x86_64-apple-darwin13.0.0/ports/libxml2/2.8.0。。。好啊
正在为libxml2.8.0运行“配置”。。。好啊
正在为libxml2 2.8.0运行“编译”。。。好啊
正在运行libxml2.8.0的“安装”。。。好啊
激活libxml2.8.0(来自/Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxml2/2.8.0)。。。
正在将libxslt-1.1.26.tar.gz提取到tmp/x86_64-apple-darwin13.0.0/ports/libxslt/1.1.26。。。好啊
正在为libxslt 1.1.26运行“配置”。。。好啊
正在为libxslt 1.1.26运行“编译”。。。好啊
正在为libxslt 1.1.26运行“安装”。。。好啊
激活libxslt 1.1.26(来自/Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/ports/x86_64-apple-darwin13.0.0/libxslt/1.1.26)。。。
正在检查libxml/parser.h...**extconf.rb失败***
由于某些原因无法创建Makefile,可能是缺少

必要的库和/或标题。查看mkmf.log文件了解更多信息 细节。您可能需要配置选项。 提供的配置选项: --使用opt dir --选择包含 --不带opt include=${opt dir}/include --使用opt lib --不带opt lib=${opt dir}/lib --用make prog --没有make prog --srcdir=。 --库尔迪尔 --ruby=/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/bin/ruby --使用zlib dir --没有zlib dir --与zlib一起包括 --没有zlib include=${zlib dir}/include --使用zlib库 --没有zlib lib=${zlib dir}/lib --使用iconv dir --没有iconv目录 --与iconv包括 --不带iconv include=${iconv dir}/include --使用iconv库 --不带iconv lib=${iconv dir}/lib --with-xml2-dir --不带-xml2-dir --with-xml2-include --不带-xml2-include=${xml2 dir}/include --with-xml2-lib --不带-xml2-lib=${xml2 dir}/lib --使用xslt-dir --没有xslt目录 --使用xslt包括 --不带xslt include=${xslt dir}/include --使用xslt库 --不带xslt lib=${xslt dir}/lib --使用libxslt配置 --没有libxslt配置 --使用pkg配置 --没有pkg配置 --with-libxml-2.0-config --不带-libxml-2.0-config --使用libiconv配置 --没有libiconv配置 /Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:381:在“try_do”中:编译器未能生成可执行文件。(运行时错误) 您必须首先安装开发工具。 from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:506:in'try_cpp' from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:970:“查找头中的块” from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:790:in“块入检查” from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in“延迟中的块(2层)”中 from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in'open' from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:284:in“延迟中的块” from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:254:in'open' from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:280:in“推迟” from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:789:in'checking_' from/Users/micahsherman/.rvm/rubies/ruby-1.9.3-p429/lib/ruby/1.9.1/mkmf.rb:969:in'find_header' 来自extconf.rb:166:in`' Gem文件仍将安装在/Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0中以供检查。 结果记录到/Users/micahsherman/.rvm/gems/ruby-1.9.3-p429/gems/nokogiri-1.6.0/ext/nokogiri/gem_make.out
我希望能得到一些提示或建议。我使用的是Ruby 1.9.4和Rails 3.2.13,我不明白为什么这不起作用。我用的是小牛,我想这可能就是问题所在


我已经更新了xcode等。

这不是一个直接的解决方案,但为您提供了正确的方向<代码>rvm在解决自身问题方面非常可靠。遵循这些步骤,帮助
rvm
发挥其神奇作用

运行
rvm需求
查找缺少的内容

使用
rvm-pkg
(在旧版本的rvm上)或
rvm-autolibs
安装缺少的软件包

确保您阅读了rvm要求您在此过程中阅读的所有文档


成功完成后,请尝试安装
nokogiri

您已经从XCode组件或命令行安装了XCode命令行工具?正如@PeterGoldstein所说,请检查是否安装了命令行工具。转到Preferences | Downloads,并在Components下确保选中了命令行工具。另外,我认为您不需要sudo。“查看mkmf.log文件了解更多详细信息”那么您的
mkmf.log
有什么要说的呢?大约有13个mkmf.log文件。我应该找什么?另外,在XCode中,在“首选项/下载”下,没有任何命令行工具选项。它也更新为XCode 5。我不知道这是否有什么不同。顺便说一句,我对编程还是相当陌生,所以我非常感谢你们的帮助。在使用rvmIt时遇到同样的问题不一定是“直接解决方案”。按照您的步骤解决了我的机器上的类似问题。有效的解决方案是最重要的。谢谢