nokogiriのインストールで死ぬ問題
とあるアプリでbundle installしようとしたところ...
$ bundle install --path vendor/bundle <中略> Fetching nokogiri 1.9.1 Installing nokogiri 1.9.1 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/shigeyukifukuda/workspace/taskleaf/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.9.1/ext/nokogiri /Users/shigeyukifukuda/.rbenv/versions/2.5.1/bin/ruby -I /Users/shigeyukifukuda/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0 -r ./siteconf20190609-33592-18zti2b.rb extconf.rb --use-system-libraries checking if the C compiler accepts ... yes checking if the C compiler accepts -Wno-error=unused-command-line-argument-hard-error-in-future... no Building nokogiri using system libraries. pkg-config could not be used to find libxml-2.0 Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" pkg-config could not be used to find libxslt Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" pkg-config could not be used to find libexslt Please install either `pkg-config` or the pkg-config gem per gem install pkg-config -v "~> 1.1" ERROR: cannot discover where libxml2 is located on your system. please make sure `pkg-config` is installed. *** 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=/Users/shigeyukifukuda/.rbenv/versions/2.5.1/bin/$(RUBY_BASE_NAME) --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 To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/shigeyukifukuda/workspace/taskleaf/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.9.1/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/shigeyukifukuda/workspace/taskleaf/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.9.1 for inspection. Results logged to /Users/shigeyukifukuda/workspace/taskleaf/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.9.1/gem_make.out An error occurred while installing nokogiri (1.9.1), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.9.1' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.2, which depends on actioncable was resolved to 5.2.2, which depends on actionpack was resolved to 5.2.2, which depends on actionview was resolved to 5.2.2, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri
bundle configを疑う
よく出てくる brew update
とbrew install --force libxml2
をカジュアルにやっちゃうと Homebrew
で管理しているツールの細かなバージョン変化によって、その他のアプリの開発に支障が出そうなので、今回は別の方法を試してみようと思います。
おそらくこれが一番平和?な解決法な予感がしています。
結論
~/.bundle/config
の BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries"
の記述を削除すれば解決します。
$ vim ~/.bundle/config
~/.bundle/config
--- BUNDLE_GEM__TEST: "rspec" BUNDLE_GEM__MIT: "true" BUNDLE_GEM__COC: "true" BUNDLE_BUILD__NOKOGIRI: "--use-system-libraries" ←ここの行を削除する
動作確認
正常にbundle installが出来るようになりました。
$ bundle install --path vendor/bundle Your Gemfile lists the gem spring (>= 0) more than once. You should probably keep only one of them. Remove any duplicate entries and specify the gem only once (per group). While it's not a problem now, it could cause errors if you change the version of one of them later. The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. Fetching gem metadata from https://rubygems.org/............ Fetching gem metadata from https://rubygems.org/. Resolving dependencies... Using rake 12.3.2 Using concurrent-ruby 1.1.4 Using i18n 1.3.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.2 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Fetching nokogiri 1.9.1 Installing nokogiri 1.9.1 with native extensions Fetching rails-dom-testing 2.0.3 Installing rails-dom-testing 2.0.3 Fetching crass 1.0.4 Installing crass 1.0.4 Fetching loofah 2.2.3 Installing loofah 2.2.3 Fetching rails-html-sanitizer 1.0.4 Installing rails-html-sanitizer 1.0.4 Fetching actionview 5.2.2 Installing actionview 5.2.2 Fetching rack 2.0.6 Installing rack 2.0.6 Fetching rack-test 1.1.0 Installing rack-test 1.1.0 Fetching actionpack 5.2.2 Installing actionpack 5.2.2 Fetching nio4r 2.3.1 Installing nio4r 2.3.1 with native extensions Fetching websocket-extensions 0.1.3 Installing websocket-extensions 0.1.3 Fetching websocket-driver 0.7.0 Installing websocket-driver 0.7.0 with native extensions Fetching actioncable 5.2.2 Installing actioncable 5.2.2 Fetching globalid 0.4.1 Installing globalid 0.4.1 Fetching activejob 5.2.2 Installing activejob 5.2.2 Fetching mini_mime 1.0.1 Installing mini_mime 1.0.1 Fetching mail 2.7.1 Installing mail 2.7.1 Fetching actionmailer 5.2.2 Installing actionmailer 5.2.2 Fetching activemodel 5.2.2 Installing activemodel 5.2.2 Fetching arel 9.0.0 Installing arel 9.0.0 Fetching activerecord 5.2.2 Installing activerecord 5.2.2 Fetching mimemagic 0.3.3 Installing mimemagic 0.3.3 Fetching marcel 0.3.3 Installing marcel 0.3.3 Fetching activestorage 5.2.2 Installing activestorage 5.2.2 Fetching public_suffix 3.0.3 Installing public_suffix 3.0.3 Fetching addressable 2.5.2 Installing addressable 2.5.2 Fetching io-like 0.3.0 Installing io-like 0.3.0 Fetching archive-zip 0.11.0 Installing archive-zip 0.11.0 Fetching execjs 2.7.0 Installing execjs 2.7.0 Fetching autoprefixer-rails 9.4.5 Installing autoprefixer-rails 9.4.5 Fetching bindex 0.5.0 Installing bindex 0.5.0 with native extensions Fetching msgpack 1.2.4 Installing msgpack 1.2.4 with native extensions Fetching bootsnap 1.3.2 Installing bootsnap 1.3.2 with native extensions Fetching popper_js 1.14.5 Installing popper_js 1.14.5 Fetching method_source 0.9.2 Installing method_source 0.9.2 Fetching thor 0.20.3 Installing thor 0.20.3 Fetching railties 5.2.2 Installing railties 5.2.2 Fetching ffi 1.9.25 Installing ffi 1.9.25 with native extensions Fetching sassc 2.0.0 Installing sassc 2.0.0 with native extensions Fetching sprockets 3.7.2 Installing sprockets 3.7.2 Fetching sprockets-rails 3.2.1 Installing sprockets-rails 3.2.1 Fetching tilt 2.0.9 Installing tilt 2.0.9 Fetching sassc-rails 2.1.0 Installing sassc-rails 2.1.0 Fetching bootstrap 4.2.1 Installing bootstrap 4.2.1 Fetching browser 2.5.3 Installing browser 2.5.3 Using bundler 1.17.3 Fetching byebug 10.0.2 Installing byebug 10.0.2 with native extensions Fetching regexp_parser 1.3.0 Installing regexp_parser 1.3.0 Fetching xpath 3.2.0 Installing xpath 3.2.0 Fetching capybara 3.12.0 Installing capybara 3.12.0 Fetching childprocess 0.9.0 Installing childprocess 0.9.0 Fetching chromedriver-helper 2.1.0 Installing chromedriver-helper 2.1.0 Fetching coderay 1.1.2 Installing coderay 1.1.2 Fetching coffee-script-source 1.12.2 Installing coffee-script-source 1.12.2 Fetching coffee-script 2.4.1 Installing coffee-script 2.4.1 Fetching coffee-rails 4.2.2 Installing coffee-rails 4.2.2 Fetching diff-lcs 1.3 Installing diff-lcs 1.3 Fetching hpricot 0.8.6 Installing hpricot 0.8.6 with native extensions Fetching html2slim 0.2.0 Installing html2slim 0.2.0 Fetching multi_json 1.13.1 Installing multi_json 1.13.1 Fetching jbuilder 2.8.0 Installing jbuilder 2.8.0 Fetching rb-fsevent 0.10.3 Installing rb-fsevent 0.10.3 Fetching rb-inotify 0.10.0 Installing rb-inotify 0.10.0 Fetching ruby_dep 1.5.0 Installing ruby_dep 1.5.0 Fetching listen 3.1.5 Installing listen 3.1.5 Fetching pg 1.1.3 Installing pg 1.1.3 with native extensions Fetching pry 0.12.2 Installing pry 0.12.2 Fetching pry-byebug 3.6.0 Installing pry-byebug 3.6.0 Fetching pry-rails 0.3.9 Installing pry-rails 0.3.9 Fetching puma 3.12.0 Installing puma 3.12.0 with native extensions Fetching rails 5.2.2 Installing rails 5.2.2 Fetching rspec-support 3.8.0 Installing rspec-support 3.8.0 Fetching rspec-core 3.8.0 Installing rspec-core 3.8.0 Fetching rspec-expectations 3.8.3 Installing rspec-expectations 3.8.3 Fetching rspec-mocks 3.8.0 Installing rspec-mocks 3.8.0 Fetching rspec-rails 3.8.2 Installing rspec-rails 3.8.2 Fetching rubyzip 1.2.2 Installing rubyzip 1.2.2 Fetching sass-listen 4.0.0 Installing sass-listen 4.0.0 Fetching sass 3.7.2 Installing sass 3.7.2 Fetching sass-rails 5.0.7 Installing sass-rails 5.0.7 Fetching selenium-webdriver 3.141.0 Installing selenium-webdriver 3.141.0 Fetching temple 0.8.0 Installing temple 0.8.0 Fetching slim 4.0.1 Installing slim 4.0.1 Fetching slim-rails 3.2.0 Installing slim-rails 3.2.0 Fetching spring 2.0.2 Installing spring 2.0.2 Fetching spring-watcher-listen 2.0.1 Installing spring-watcher-listen 2.0.1 Fetching turbolinks-source 5.2.0 Installing turbolinks-source 5.2.0 Fetching turbolinks 5.2.0 Installing turbolinks 5.2.0 Fetching uglifier 4.1.20 Installing uglifier 4.1.20 Fetching web-console 3.7.0 Installing web-console 3.7.0 Bundle complete! 26 Gemfile dependencies, 100 gems now installed. Bundled gems are installed into `./vendor/bundle` Post-install message from sass: Ruby Sass is deprecated and will be unmaintained as of 26 March 2019. * If you use Sass as a command-line tool, we recommend using Dart Sass, the new primary implementation: https://sass-lang.com/install * If you use Sass as a plug-in for a Ruby web framework, we recommend using the sassc gem: https://github.com/sass/sassc-ruby#readme * For more details, please refer to the Sass blog: http://sass.logdown.com/posts/7081811