Ruby 安装 nokogiri Failed to build gem native extension

actberw · 2012年10月19日 · 最后由 Seabornlee 回复于 2014年05月29日 · 10537 次阅读

今天在安装 redmine 和插件 backlogs,提示:

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

/home/xxxx/.rvm/rubies/ruby-1.9.3-head/bin/ruby extconf.rb 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.

也安装了 libxslt-dev libxml2-dev

shell > find /usr/include/ -name libxml /usr/include//libxml2/libxml

想按照 http://kenjiru.ro/blog/2012/02/install-the-backlogs-plugin-for-redmine-on-hostgator 来直接 compile,指定位置: shell > gem compile nokogiri-1.5.5.gem --with-xml2-include=/usr/include/libxml2

却提示 invalid option: --with-xml2-include=/usr/include/libxml2

用了 rvm,ruby 版本是 ruby-1.9.3-head,系统是: Distributor ID: Debian Description: Debian GNU/Linux 6.0.5 (squeeze) Release: 6.0.5 Codename: squeeze

对 ruby 不熟,求帮忙,万分感谢!

Check the mkmf.log file for more details.

#1 楼 @yangkit thx, 里面提示 package configuration for libiconv is not found shell> aptitude search libiconv p libiconv-hook-dev - header files of libiconv-hook
p libiconv-hook1 - extension of iconv for libapache-mod-encoding
v libiconv-ruby -
v libiconv-ruby1.8 都装了,是哪出的问题?

http://stackoverflow.com/questions/11354464/trouble-installing-nokogiri-with-rvm-1-9-3-on-centos-6-2 这个问题类似,解决方案就是删除用 rvm pkg 安装的包,有没有其他办法?

/usr/lib/gcc/x86_64-linux-gnu/4.6/../../../x86_64-linux-gnu/libxml2.so: undefined reference to `gzopen64@ZLIB_1.2.3.3' 应该是这错了。

libxml 版本:Version: 2.8.0+dfsg1-5 zlib 版本:Version: 1:1.2.3.4.dfsg-3 问题就是出在这了,怎么来降低 zlib 的版本?

把 zlib 降低到版本 1.2.3.3 依然还是不行啊。

处理好了,是 libxml2 的版本的问题,debian 源中最新的版本是 2.7.8.dfsg-2+squeeze5,不知道谁装了个 2.8.0 版本。

求问楼主,遇到一样的问题,如何把 libxml2 重装了 或者 设定为 2.7.8 版本

sudo apt-get install ruby-dev 我是这样解决的。

需要 登录 后方可回复, 如果你还没有账号请 注册新账号