### native extension を利用する gem のインストールに失敗する
Railsでアプリ開発をしようともい、Railsのインストールを試みる。すると下記のようなエラーコードが出てきました。自分なりに呼んだのですがどうも**nokogiri**のインストールでつまずいている模様。解決の可能性だけでも浮かんだ方がいましたら返答お願いしたいです。
ドットインストールでずっと勉強していたため、環境はWin10上にVagrantでCentOSを載せています。
エラーコード
ERROR: Error installing rails: ERROR: Failed to build gem native extension.
エラー全文
[vagrant@localhost ~]$ gem install rails -v 5.1.3 --no-document Fetching actionpack-5.1.3.gem Fetching rack-test-0.6.3.gem Fetching actionview-5.1.3.gem Fetching activesupport-5.1.3.gem Fetching i18n-0.9.5.gem Fetching actioncable-5.1.3.gem Fetching rails-5.1.3.gem Fetching railties-5.1.3.gem Fetching activejob-5.1.3.gem Fetching actionmailer-5.1.3.gem Fetching arel-8.0.0.gem Fetching activemodel-5.1.3.gem Fetching activerecord-5.1.3.gem Fetching websocket-driver-0.6.5.gem Successfully installed i18n-0.9.5 Successfully installed activesupport-5.1.3 Building native extensions. This could take a while... ERROR: Error installing rails: ERROR: Failed to build gem native extension. current directory: /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/ext/nokogiri /home/vagrant/.rbenv/versions/2.6.5/bin/ruby -I /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/site_ruby/2.6.0 -r ./siteconf20191006-28714-1175yzn.rb extconf.rb checking if the C compiler accepts ... yes Building nokogiri using packaged libraries. Using mini_portile version 2.4.0 checking for gzdopen() in -lz... yes checking for iconv... yes ************************************************************************ IMPORTANT NOTICE: Building Nokogiri with a packaged version of libxml2-2.9.10 with the following patches applied: - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch - 0002-Remove-script-macro-support.patch - 0003-Update-entities-to-remove-handling-of-ssi.patch Team Nokogiri will keep on doing their best to provide security updates in a timely manner, but if this is a concern for you and want to use the system library instead; abort this installation process and reinstall nokogiri as follows: gem install nokogiri -- --use-system-libraries [--with-xml2-config=/path/to/xml2-config] [--with-xslt-config=/path/to/xslt-config] If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install Note, however, that nokogiri is not fully compatible with arbitrary versions of libxml2 provided by OS/package vendors. ************************************************************************ Extracting libxml2-2.9.10.tar.gz into tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.10... OK Running git apply with /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/patches/libxml2/0001-Revert-Do-not-URI-escape-in-server-side-includes.patch... OK Running git apply with /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/patches/libxml2/0002-Remove-script-macro-support.patch... OK Running git apply with /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/patches/libxml2/0003-Update-entities-to-remove-handling-of-ssi.patch... OK Running 'configure' for libxml2 2.9.10... ERROR, review '/home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5/ext/nokogiri/tmp/x86_64-pc-linux-gnu/ports/libxml2/2.9.10/configure.log' to see what happened. Last lines are: ======================================================================== configure: WARNING: you should use --build, --host, --target checking whether to enable maintainer-specific portions of Makefiles... yes checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking for a BSD-compatible install... /usr/bin/install -c checking whether build environment is sane... configure: error: newly created file is older than distributed files! Check your system clock ======================================================================== *** 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/vagrant/.rbenv/versions/2.6.5/bin/$(RUBY_BASE_NAME) --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/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:402:in `block in execute': Failed to complete configure task (RuntimeError) from /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `chdir' from /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:373:in `execute' from /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:110:in `configure' from /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mini_portile2-2.4.0/lib/mini_portile2/mini_portile.rb:153:in `cook' from extconf.rb:365:in `block (2 levels) in process_recipe' from extconf.rb:257:in `block in chdir_for_build' from extconf.rb:256:in `chdir' from extconf.rb:256:in `chdir_for_build' from extconf.rb:364:in `block in process_recipe' from extconf.rb:262:in `tap' from extconf.rb:262:in `process_recipe' from extconf.rb:557:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/nokogiri-1.10.5/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/nokogiri-1.10.5 for inspection. Results logged to /home/vagrant/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/extensions/x86_64-linux/2.6.0-static/nokogiri-1.10.5/gem_make.out
試したこと
Rubyの再インストール、
gemのアップデート
gccのアップデート
### エラーの解読
エラーコードに書いてある、
gem install nokogiri -- --use-system-libraries [--with-xml2-config=/path/to/xml2-config] [--with-xslt-config=/path/to/xslt-config] If you are using Bundler, tell it to use the option: bundle config build.nokogiri --use-system-libraries bundle install
は一通り試しました。
gem install nokogiri -- --use-system-libraries
では↓を実行しなさいと言われたので
gem install pkg-config -v "~> 1.1"
を実行、このGemのインストールはできたものの、再度nokogiriのインストールをしても初期のエラーと変わらず...
最後の bundle install はそもそもGemFileが存在しないため実行できませんでした。
回答2件
あなたの回答
tips
プレビュー