web-dev-qa-db-ja.com

nokogiri 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.

ホストから、すべてのライブラリがインストールされていると言われました。 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>'
63
Claudiu Creanga

最後に、この問題は、一部のシステムと互換性のない独自のlibxml2を出荷することにより、nokogiri自体が原因で発生しました。
したがって、nokogiriをインストールするには、システムライブラリを使用するように指示する必要がありました。

私は手動でインストールしました:

gem install nokogiri -v 1.6.2.1 -- --use-system-libraries

そしてそれはうまくいきました。他の答えはそれを解決しませんでした。

49
Claudiu Creanga

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が自動的にインストールを試み、痛みを感じます。

詳細はこの投稿をご覧ください

134
Zigii Wong

リストされていないビルドの依存関係のため、私はこの同じ問題に遭遇しました。問題のtmpディレクトリを見つけたとき:

find ~/.rbenv/ -name patch.log

と言いました:

sh:パッチ:コマンドが見つかりません

簡単にそれを修正しました:

Sudo yum install -y patch
24
billwanjohi

OSX Yosemiteでは、xcode-select --installターミナルで。その後、bundleはそのgemで問題なく動作しました。

18

これは、Windows 7 Home Basic 64ビットで動作します:

gem install nokogiri -v 1.6.2.1 -- --use-system-libraries

現在の回答では何もうまくいきませんでした(MacではなくUbuntu 16.04を使用しています)。

ただし、 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&Cs :)に準拠しません。

3
Riccardo

これはOS X Yosemiteでうまくいきました。

gem install nokogiri -v 1.6.5 -- --use-system-libraries
3
jason328

Mac OS El CapitanにNokogiriをインストールする:

brew install libxml2bundle config build.nokogiri "--use-system-libraries --with-xml2-include=/usr/local/opt/libxml2/include/libxml2"

bundle install

それは私のために働いています:)

3
Anil Yadav

これはOS X 10.10.3 Yosemiteで私のために働いたものです:

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
2
Adam

Nokogiriは、実行するまでOSX SierraマシンでXcodeライブラリを見つけられませんでした。

Sudo xcodebuild -license accept

2

Just Like 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/

2
Gus

これは私のために働いた:

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
1
Will Hodges

私の場合、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

インストール後、インストールは問題なく終了しました。

0
Samuel Morais

最後に、多くの苦労の末、私にとっては以下がうまくいきました(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 
0
Victor Vorski