2014-09-30 61 views
0

我试图设置一个新的Redhat VM来运行我的Redhat Ruby on Rails应用程序。Nokogiri在Redhat虚拟机上安装失败

我想bundle install,它不工作。它一直告诉我要安装Nokogiri,但我确实安装了它,但仍然出现错误。

这是我如何安装引入nokogiri

$ sudo gem install nokogiri -v 1.5.11 

Building native extensions. This could take a while... 
Successfully installed nokogiri-1.5.11 
1 gem installed 

然后,在我的Rails应用程序我做bundle install,我得到这个错误:

Installing nokogiri (1.5.11) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. 

    /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/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. 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=/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/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 
    /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/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 /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:506:in `try_cpp' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:970:in `block in find_header' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:790:in `block in checking_for' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block (2 levels) in postpone' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `block in postpone' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:254:in `open' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:280:in `postpone' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:789:in `checking_for' 
from /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:969:in `find_header' 
from extconf.rb:116:in `<main>' 


Gem files will remain installed in /home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11 for inspection. 
Results logged to /home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11/ext/nokogiri/gem_make.out 

An error occurred while installing nokogiri (1.5.11), and Bundler cannot 
continue. 
Make sure that `gem install nokogiri -v '1.5.11'` succeeds before bundling. 

的思考?

回答

0

尝试访问mkmf.log文件并查看那里列出的信息。我在Mac OS上遇到了类似的问题,我记得不得不删除一个文件,因为它已损坏。

+0

哪里这是mkmf.log? – jrock2004 2014-10-01 12:27:28

1

按照这里的指南:http://nokogiri.org/tutorials/installing_nokogiri.html工作我安装使用Homebrew 0.9下面是他们推荐红帽。

红帽/ CentOS的

最简单的方式获得在CentOS和RHEL安装引入nokogiri似乎是EPEL软件库包含一个预置的引入nokogiri包。要使用它,安装相应的EPEL释放包为您的操作系统,然后运行:

sudo yum install -y rubygem-nokogiri 

要安装使用宝石安装是因为从中央库包的年龄稍微复杂一些。如果您安装了rubygems,则可以通过gem install来安装nokogiri。如果您运行介绍问题,请尝试安装这些软件包。

sudo yum install -y gcc ruby-devel libxml2 libxml2-devel libxslt libxslt-devel 

的CentOS 5(RHEL5和)前来安装了libxml的2.6.26它,而不是进攻外的日期的Mac Leopard的,仍然是相当该死的旧(2006年6月发布),并已知问题。

如果您受到任何已知错误的影响或者看到奇怪的行为,您可能需要考虑卸载libxml2和libxslt的RPM,并从源代码构建它们。

须藤荫删除-y的libxml2-devel的的libxslt-devel的 下载从ftp://xmlsoft.org/libxml2/ 的./configure最近libxml2和的libxslt;制造须藤使安装 然后安装引入nokogiri指定libxml2和的libxslt安装目录:

sudo gem install nokogiri -- --with-xml2-lib=/usr/local/lib 
          --with-xml2-include=/usr/local/include/libxml2 
          --with-xslt-lib=/usr/local/lib 
          --with-xslt-include=/usr/local/include 

(需要注意的是,默认情况下的libxslt头文件安装到根包括目录,但libxml2的头文件安装到子目录中其命名为libxml2。)

或者,您知道,您安装了libxml和libxslt的任何目录。祝你好运。

1

Here is how I installed nokogiri

$ sudo gem install nokogiri -v 1.5.11 

...

/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 

您使用sudo当你使用个人RVM沙箱安装引入nokogiri。不要这样做。该RVM directions for installing gems特别说:

DO NOT use sudo...

to work with RVM gems. When you do sudo you are running commands as root, another user in another shell and hence all of the setup that RVM has done for you is ignored while the command runs under sudo (such things as GEM_HOME, etc...). So to reiterate, as soon as you 'sudo' you are running as the root system user which will clear out your environment as well as any files it creates are not able to be modified by your user and will result in strange things happening. (You will start to think that someone has a voodoo doll of your application...)

下一页:

checking for libxml/parser.h... *** extconf.rb failed *** 

你好像缺少devel的包的libxml。

0

挣扎了几个小时与此错误,最后是我需要的是:

yum install cmake 

欢呼

0

在CentOS缺少的编译环境是我的宝石问题的原因:

yum install gcc 
yum install cmake 
yum install ruby-devel