不能在CentOS上安装Nokogiri,而不需要更高的Ruby版本?

时间:2022-09-14 17:05:31

Below is what I tried on my CentOS6.5 server. I have already updated Git and Ruby, but still can't get it to install. The first section is where I tried to install it as a sudo user. The second section is when I Tried to install it by root.

下面是我在CentOS6.5服务器上的尝试。我已经更新了Git和Ruby,但是仍然无法安装。第一部分是我试图将其安装为sudo用户的地方。第二部分是当我尝试安装它的根。

Can anyone offer other ideas on how to fix this? I am having a hard time finding any fixes for this issue.

有人能提出其他的解决方法吗?我很难找到解决这个问题的方法。

Section 1:

第一节:

[user@server gitlab-rails]$ sudo gem install nokogiri -- --use-system-libraries
[sudo] password for user:
Fetching: mini_portile-0.6.2.gem (100%)
Successfully installed mini_portile-0.6.2
Fetching: nokogiri-1.6.6.2.gem (100%)
ERROR:  Error installing nokogiri:
    nokogiri requires Ruby version >= 1.9.2.
[user@server gitlab-rails]$ ruby --version
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]

Section 2:

第二节:

[root@server gitlab-rails]# gem install nokogiri -- --use-system-libraries
Building native extensions with: '--use-system-libraries'
This could take a while...
ERROR:  Error installing nokogiri:
        ERROR: Failed to build gem native extension.

/usr/local/bin/ruby extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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/local/bin/ruby
        --help
        --clean
        --use-system-libraries
        --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-xml2-dir
        --without-xml2-dir
        --with-xml2-include
        --without-xml2-include=${xml2-dir}/include
        --with-xml2-lib
        --without-xml2-lib=${xml2-dir}/lib
        --with-libxml-2.0-config
        --without-libxml-2.0-config
        --with-pkg-config
        --without-pkg-config
        --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-exslt-dir
        --without-exslt-dir
        --with-exslt-include
        --without-exslt-include=${exslt-dir}/include
        --with-exslt-lib
        --without-exslt-lib=${exslt-dir}/lib
        --with-libexslt-config
        --without-libexslt-config

extconf failed, exit code 1

Gem files will remain installed in /usr/local/lib/ruby/gems/2.1.0/gems/nokogiri-1.6.6.2 for inspection.
Results logged to /usr/local/lib/ruby/gems/2.1.0/extensions/x86_64-linux/2.1.0-static/nokogiri-1.6.6.2/gem_make.out

3 个解决方案

#1


4  

yum install libxslt-devel libxml2-devel
bundle config build.nokogiri --use-system-libraries
bundle install

#2


1  

These error messages appear to me to be pretty clear-cut: you're using an old ruby in the first instance (and running into Rubygems behavior (not Nokogiri behavior)), and trying to link to an old (known-buggy) version of libxml2 in the second (this is Nokogiri's sanity check).

这些错误消息在我看来是相当明确的:您在第一个实例中使用了一个老ruby(并运行Rubygems行为(而不是Nokogiri行为)),并试图在第二个(这是Nokogiri的完整性检查)中链接到libxml2的一个旧版本(known-buggy)版本。

If you want to "fix" it, make sure you're using the right Ruby version, and either install an acceptable libxml2 or let Nokogiri use its vendored versions for you.

如果您想要“修复”它,请确保您使用的是正确的Ruby版本,或者安装一个可接受的libxml2,或者让Nokogiri为您使用它的版本。

#3


0  

After working with someone who is more familiar with CentOS, I discovered that the issue was being caused by not having cmake installed as well as trying to install a gem through sudo.

在和一个更熟悉CentOS的人合作之后,我发现这个问题是由于没有安装cmake,并试图通过sudo安装gem。

Tip: When installing gems always use the root user.

提示:在安装gems时,总是使用根用户。

#1


4  

yum install libxslt-devel libxml2-devel
bundle config build.nokogiri --use-system-libraries
bundle install

#2


1  

These error messages appear to me to be pretty clear-cut: you're using an old ruby in the first instance (and running into Rubygems behavior (not Nokogiri behavior)), and trying to link to an old (known-buggy) version of libxml2 in the second (this is Nokogiri's sanity check).

这些错误消息在我看来是相当明确的:您在第一个实例中使用了一个老ruby(并运行Rubygems行为(而不是Nokogiri行为)),并试图在第二个(这是Nokogiri的完整性检查)中链接到libxml2的一个旧版本(known-buggy)版本。

If you want to "fix" it, make sure you're using the right Ruby version, and either install an acceptable libxml2 or let Nokogiri use its vendored versions for you.

如果您想要“修复”它,请确保您使用的是正确的Ruby版本,或者安装一个可接受的libxml2,或者让Nokogiri为您使用它的版本。

#3


0  

After working with someone who is more familiar with CentOS, I discovered that the issue was being caused by not having cmake installed as well as trying to install a gem through sudo.

在和一个更熟悉CentOS的人合作之后,我发现这个问题是由于没有安装cmake,并试图通过sudo安装gem。

Tip: When installing gems always use the root user.

提示:在安装gems时,总是使用根用户。