我知道有很多关于这个宝石的问题,但没有答案对我有用。
当我在SSH gem install nokogiri
中运行时,我收到此错误:
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0... OK
Running patch with /home/user58952277/.gem/ruby/1.9.3/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0/patch.log' to see what happened.
*** 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.
我的主人告诉我所有的lib都已安装。 以下是执行install nokogiri命令后的完整日志:
Building native extensions. This could take a while...
Building nokogiri using packaged libraries.
Building libxml2-2.8.0 for nokogiri with the following patches applied:
- 0001-Fix-parser-local-buffers-size-problems.patch
- 0002-Fix-entities-local-buffers-size-problems.patch
- 0003-Fix-an-error-in-previous-commit.patch
- 0004-Fix-potential-out-of-bound-access.patch
- 0005-Detect-excessive-entities-expansion-upon-replacement.patch
- 0006-Do-not-fetch-external-parsed-entities.patch
- 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
- 0008-Improve-handling-of-xmlStopParser.patch
- 0009-Fix-a-couple-of-return-without-value.patch
- 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
- 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT! Nokogiri builds and uses a packaged version of libxml2.
If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:
gem install nokogiri -- --use-system-libraries
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
However, note that nokogiri does not necessarily support all versions
of libxml2.
For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
ERROR: Error installing nokogiri:
ERROR: Failed to build gem native extension.
/opt/rubies/ruby-1.9.3/bin/ruby extconf.rb
Building nokogiri using packaged libraries.
checking for iconv.h... yes
checking for iconv_open() in iconv.h... yes
Building libxml2-2.8.0 for nokogiri with the following patches applied:
- 0001-Fix-parser-local-buffers-size-problems.patch
- 0002-Fix-entities-local-buffers-size-problems.patch
- 0003-Fix-an-error-in-previous-commit.patch
- 0004-Fix-potential-out-of-bound-access.patch
- 0005-Detect-excessive-entities-expansion-upon-replacement.patch
- 0006-Do-not-fetch-external-parsed-entities.patch
- 0007-Enforce-XML_PARSER_EOF-state-handling-through-the-pa.patch
- 0008-Improve-handling-of-xmlStopParser.patch
- 0009-Fix-a-couple-of-return-without-value.patch
- 0010-Keep-non-significant-blanks-node-in-HTML-parser.patch
- 0011-Do-not-fetch-external-parameter-entities.patch
************************************************************************
IMPORTANT! Nokogiri builds and uses a packaged version of libxml2.
If this is a concern for you and you want to use the system library
instead, abort this installation process and reinstall nokogiri as
follows:
gem install nokogiri -- --use-system-libraries
If you are using Bundler, tell it to use the option:
bundle config build.nokogiri --use-system-libraries
bundle install
However, note that nokogiri does not necessarily support all versions
of libxml2.
For example, libxml2-2.9.0 and higher are currently known to be broken
and thus unsupported by nokogiri, due to compatibility problems and
XPath optimization bugs.
************************************************************************
Extracting libxml2-2.8.0.tar.gz into tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0... OK
Running patch with /home/user58952277/.gem/ruby/1.9.3/gems/nokogiri-1.6.2.1/ports/patches/libxml2/0001-Fix-parser-local-buffers-size-problems.patch...
Running 'patch' for libxml2 2.8.0... ERROR, review 'tmp/x86_64-unknown-linux-gnu/ports/libxml2/2.8.0/patch.log' to see what happened.
*** 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=/opt/rubies/ruby-1.9.3/bin/ruby
--help
--clean
--use-system-libraries
--enable-static
--disable-static
--with-zlib-dir
--without-zlib-dir
--with-zlib-include
--without-zlib-include=${zlib-dir}/include
--with-zlib-lib
--without-zlib-lib=${zlib-dir}/lib
--enable-cross-build
--disable-cross-build
/home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:279:in `block in execute': Failed to complete patch task (RuntimeError)
from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:271:in `chdir'
from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:271:in `execute'
from extconf.rb:282:in `block in patch'
from extconf.rb:279:in `each'
from extconf.rb:279:in `patch'
from /home/user58952277/.gem/ruby/1.9.3/gems/mini_portile-0.6.0/lib/mini_portile.rb:108:in `cook'
from extconf.rb:253:in `block in process_recipe'
from extconf.rb:154:in `tap'
from extconf.rb:154:in `process_recipe'
from extconf.rb:419:in `<main>'
答案 0 :(得分:134)
macOS High Sierra 10.13
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.13.sdk/usr/include/libxml2/
macOS Sierra 10.12:
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/
OS X El Capitan 10.11
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2/
如果您没有权限,请考虑添加sudo
。
出于某种原因,Apple的Yosemite OSX版本没有libxml2的系统可访问安装。 Nokogiri需要这个才能编译,幸运的是Xcode有一个与之捆绑的libxml2版本 - 我们只需要在安装gem时指定它。让Nokogiri正确安装非常重要,因为到目前为止,Rails 4.2.1.rc4会自动尝试安装它,你会感到痛苦。
答案 1 :(得分:46)
最后,问题是nokogiri本身通过运送它自己的libxml2引起的,这与某些系统不兼容。
所以要安装nokogiri,我必须告诉它它应该使用系统库。
我通过以下方式手动安装:
gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
它运作良好。其他答案没解决。
答案 2 :(得分:24)
由于未列出的构建依赖性,我遇到了同样的问题。当我找到有问题的tmp目录时:
find ~/.rbenv/ -name patch.log
它说:
sh:patch:找不到命令
修正了一个简单的问题:
sudo yum install -y patch
答案 3 :(得分:18)
在OSX Yosemite上,我在终端中做了xcode-select --install
。之后,bundle
与该宝石一起工作正常。
答案 4 :(得分:4)
这适用于Windows 7 Home Basic 64位:
var dataObj = {
userId:userId,
paymentMethod:paymentMethod,
product:product,
status:status
}
答案 5 :(得分:3)
这适用于OS X Yosemite。
gem install nokogiri -v 1.6.5 -- --use-system-libraries
答案 6 :(得分:3)
目前的答案中没有任何内容适用于我(我使用的是Ubuntu 16.04,而不是Mac)。
然而,按照Nokogiri site中的说明进行操作,这部分就是诀窍:
# See http://www.nokogiri.org/tutorials/installing_nokogiri.html#ubuntu___debian
sudo apt-get install build-essential patch
sudo apt-get install ruby-dev zlib1g-dev liblzma-dev
注意我自2009年以来一直在使用Nokogiri,而且我一直无法安装它。任何进一步的评论都可能不符合SO T&amp; Cs:)
答案 7 :(得分:2)
这对OS X 10.10.3优胜美地有用:
sudo gem install nokogiri -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/usr/lib
答案 8 :(得分:2)
就像wongzigii说的那样,install命令可以与那些带有macOS Sierra的标志一起使用
gem install nokogiri -- --use-system-libraries=true --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/libxml2/
答案 9 :(得分:2)
Nokogiri在我的OSX Sierra机器上找不到Xcode库,直到我跑:
sudo xcodebuild -license accept
答案 10 :(得分:1)
这对我有用:
sudo gem install nokogiri -v 'versionNumber' -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/usr/lib
答案 11 :(得分:0)
经过多次努力,以下对我有用(OS X 10.8.5,macports)。 (我正在安装github页面,即jekyll)
/opt/local/bin/gem install nokogiri -v 1.6.6.2 -- --use-system-libraries --with-xslt-dir=/usr/local/opt/libxslt --with-xml2-include=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/libxml2 --with-xml2-lib=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/lib
答案 12 :(得分:0)
就我而言,我使用的是Mac OSX Mojave,必须安装此处描述的软件包:https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624
这是包的路径: /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
安装后,安装顺利完成。
答案 13 :(得分:0)
我想出了很难的方法,花了几个小时来追踪面包屑,并阅读人们正在尝试的内容。没有任何帮助。溢出页面上的所有内容都无济于事,所以这是我解决此问题的方法:
如果您将机器用于ruby
以外的其他开发项目。您可能要检查软件包管理器的其他语言安装。更重要的是-您可能要检查其他c编译器的安装-即clang
在我的情况下-我已经安装了anaconda/conda(python)
,并替换了.bash_profile
中的一堆路径,以将clang
用作主要的c编译器,其中xcode command line tools
和{ {1}}都使用了先前通过Homebrew安装的rebenv
。
我删除了gcc
和anaconda(using anaconda-clean)
安装,然后尝试捆绑。那是我遇到clang
问题的时候。然后,我通过自制程序missing libxml2
来确保通过REINSTALLED libxml2
重做符号链接,并按照随后的说明将适当的homebrew
添加到我的export flags
文件中。
现在成功捆绑。原因是,宝石现在与我用于该项目的红宝石版本捆绑在同一编译器中。
对于像我们中许多人一样的多语言开发机器,Docker会使其成为一个非问题。
所以抬头。
答案 14 :(得分:0)
步骤1:
brew install libxml2
第2步:
bundle config build.nokogiri --use-system-libraries
步骤3: 然后尝试
捆绑安装
答案 15 :(得分:-2)
使用macOS Sierra。
去了nokogiri文档并遵循这个:
ON MAC OSX
使用Nokogiri的libxml2和libxslt安装Just Work™。
首先,确保您拥有最新版本的RubyGems和xcode命令行工具:
1 gem update --system
2 xcode-select --install
然后安装nokogiri:
1 gem install nokogiri