Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.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 在Redhat VM上安装Nokogiri失败_Ruby On Rails_Ruby_Nokogiri - Fatal编程技术网

Ruby on rails 在Redhat VM上安装Nokogiri失败

Ruby on rails 在Redhat VM上安装Nokogiri失败,ruby-on-rails,ruby,nokogiri,Ruby On Rails,Ruby,Nokogiri,我正在尝试设置一个新的Redhat VM,它将运行我的Redhat Ruby on Rails应用程序 我正在尝试捆绑安装,但它不起作用。它一直告诉我安装Nokogiri,但我确实安装了它,但我仍然得到错误 下面是我如何安装Nokogiri的 $ sudo gem install nokogiri -v 1.5.11 Building native extensions. This could take a while... Successfully installed nokogiri-1

我正在尝试设置一个新的Redhat VM,它将运行我的Redhat Ruby on Rails应用程序

我正在尝试
捆绑安装
,但它不起作用。它一直告诉我安装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应用程序中,我进行了
捆绑安装
,并出现以下错误:

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.
安装nokogiri(1.5.11)
Gem::Installer::ExtensionBuildError:错误:无法生成Gem本机扩展。
/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby-extconf.rb
正在检查libxml/parser.h...**extconf.rb失败***
由于某些原因无法创建Makefile,可能是缺少
必要的库和/或标题。查看mkmf.log文件了解更多信息
细节。您可能需要配置选项。
提供的配置选项:
--使用opt dir
--不带opt dir
--选择包含
--不带opt include=${opt dir}/include
--使用opt lib
--不带opt lib=${opt dir}/lib
--用make prog
--没有make prog
--srcdir=。
--库尔迪尔
--ruby=/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/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配置
/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:381:在“try_do”中:编译器未能生成可执行文件。(运行时错误)
您必须首先安装开发工具。
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:在“查找头中的块”中
from/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:790:in“块入检查”
from/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:284:in `中的块(2层)'
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“延迟中的块”
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“推迟”
from/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:789:in'checking_'
from/home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/mkmf.rb:969:in'find_header'
来自extconf.rb:116:in`'
Gem文件仍将安装在/home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11中以供检查。
结果记录到/home/gsidevas/.rvm/gems/ruby-1.9.3-p448/gems/nokogiri-1.5.11/ext/nokogiri/gem_make.out
安装nokogiri(1.5.11)时出错,Bundler无法启动
继续。
在绑定之前,确保'gem install nokogiri-v'1.5.11'成功。

想法?

尝试访问mkmf.log文件,查看其中列出的信息。我在Mac OS上也遇到过类似的问题,我记得因为文件已损坏而不得不删除该文件。

遵循此处的指南:使用以下自制0.9为我的安装工作是他们推荐的Red Hat

红帽

在CentOS和RHEL上安装Nokogiri的最简单方法似乎是包含预构建Nokogiri包的EPEL存储库。要使用它,请为您的操作系统安装适当的epel发行包,然后运行:

sudo yum install -y rubygem-nokogiri
使用gem-install进行安装有点复杂,因为中央存储库提供的软件包已经过时。如果您已经安装了rubygems,您可以通过gem安装来安装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月发布),并且存在已知的问题

如果您受到任何已知的bug或看到奇怪行为的影响,您可能需要考虑卸载RPXML2和LIXSLT的RPM,并从源建立它们。

sudo yum remove-y libxml2-devel libxslt-devel 从下载最新的libxml2和libxslt /配置;制作sudo制作安装 然后安装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头文件安装在根include目录中,但libxml2头文件安装在其名为libxml2的子目录中。)

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

下面是我如何安装nokogiri的

当您使用个人RVM沙箱时,您使用
sudo
安装Nokogiri。不要那样做。报告明确指出:

不要使用sudo

使用RVM gems。当您执行sudo时,您正在以root用户身份运行命令,另一个shell中的另一个用户以及因此RVM为您执行的所有设置将被忽略,而命令在sudo下运行(例如GEM_HOME等)。因此,重申一下,一旦您“sudo”以根系统用户的身份运行,它将清除您的环境以及它创建的任何文件,这些文件不能被您的用户修改,并将导致奇怪的事情发生。(你会开始认为有人在你的应用程序中有一个巫毒娃娃…)

下一步:

$ sudo gem install nokogiri -v 1.5.11
    /home/gsidevas/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb 
checking for libxml/parser.h... *** extconf.rb failed ***
yum install cmake
yum install gcc
yum install cmake
yum install ruby-devel