nokogirigem安装错误
我知道关于这个gem有很多问题,但没有答案为我工作。
当我在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.
我的主机告诉我,所有的库都安装好了。 以下是执行安装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>'
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
。
出于某种原因,苹果公司的优胜美地版本OSX没有系统可访问的libxml2安装。 Nokogiri需要这个才能进行编译,幸运的是Xcode有一个与它捆绑在一起的libxml2版本 – 我们只需要在安装gem的时候指定它。 正确安装Nokogiri是非常重要的,因为从现在开始,Rails 4.2.1.rc4会自动尝试安装它,您将感到痛苦。
结帐这个职位了解更多信息 。
最后,这个问题是由nokogiri本身引起的,它自己的libxml2与某些系统不兼容。
所以要安装nokogiri我不得不告诉它,它应该使用系统库。
我手动安装它:
gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
它运作良好。 其他答案没有解决它。
我遇到了同样的问题,因为未列出的构build依赖关系。 当我find有问题的tmp目录时:
find ~/.rbenv/ -name patch.log
它说:
sh:patch:找不到命令
修正了一个简单的问题:
sudo yum install -y patch
在OSX优胜美地,我做了xcode-select --install
在terminal。 之后, bundle
工作与该gem罚款。
这适用于Windows 7家庭普通版64位:
gem install nokogiri -v 1.6.2.1 -- --use-system-libraries
这与OS X优胜美地为我工作。
gem install nokogiri -v 1.6.5 -- --use-system-libraries
这是在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
就像wongzigii说,安装命令与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/
在Mac OS上安装Nokogiri El Capitan:
brew install libxml2
bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"
bundle install
它为我工作:)
这对我工作:
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
目前的答案没有为我工作(我使用Ubuntu 16.04,而不是Mac)。
然而,按照Nokogiri网站的说明,这部分就是这样做的:
# 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&C 🙂
最后经过了很多努力,以下为我工作(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
我正在使用macOS Sierra。
去nokogiri文件,并按照这个:
在MAC OSX上
使用Nokogiri的售货libxml2和libxslt,安装应该Just Work™。
首先,确保你有最新版本的RubyGems和xcode命令行工具:
1 gem update --system
2 xcode-select --install
然后安装nokogiri:
1 gem install nokogiri
在我运行之前,Nokogiri没有在我的OSX Sierra机器上findXcode库:
sudo xcodebuild -license accept