安装nokogiri 以及gem 的时候错误总结

1、第一个错误信息

==============================================================================

ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.

        /usr/bin/ruby1.9.1 extconf.rb
/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- mkmf (LoadError)
from /usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from extconf.rb:5:in `
'

Gem files will remain installed in /var/lib/gems/1.9.1/gems/nokogiri-1.5.10 for inspection.
Results logged to /var/lib/gems/1.9.1/gems/nokogiri-1.5.10/ext/nokogiri/gem_make.out


===============================================================================
问题:你尝试去安装一个gem, 但是遇到了一个“缺少mkmf”的读取错误。
它不经常发生,当你试图使用原生的C代码去编译安装gem就会发生。

解决方法:安装操作系统的开发环境。  大部分的操作系统不会配备C编译器和相关的
构建工具。
linux下的命令行:

sudo apt-get install build-essential libopenssl-ruby ruby1.9.1-dev


【ruby1.9.1-dev 其中的数字就是版本号。】


2、第二个终端错误信息:
=====================================================================================

ERROR:  Error installing nokogiri:
ERROR: Failed to build gem native extension.


        /usr/bin/ruby1.9.1 extconf.rb
checking for libxml/parser.h... no
-----
libxml2 is missing.  please visit http://nokogiri.org/tutorials/installing_nokogiri.html for help with installing dependencies.
-----
*** 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
--without-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=/usr/bin/ruby1.9.1
--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
=====================================================================================
错误log文件:/home/administrator/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.10/ext/nokogiri/mkmf.log 内容如下:
ackage configuration for libxslt
cflags: -I/usr/include/libxml2
ldflags:
libs: -lxslt -lxml2


package configuration for libxml-2.0
cflags: -I/usr/include/libxml2
ldflags:
libs: -lxml2


package configuration for libiconv is not found
find_header: checking for libxml/parser.h... -------------------- yes

解决方法:
sudo apt-get install libxslt-dev libxml2-dev

再次运行 gem install nokogiri -v '1.5.10'  成功 

你可能感兴趣的:(Android,Related)