2014-09-30 68 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