前提・実現したいこと
railsでWebアプリ開発に取り組もうとしている初心者です。
職場でまず環境構築に取り組んだのですが、
・rubyおよびrbenvといった基本的な部分は正常にインストール、バージョンも最新
・仕事とは別の自分のrails環境にはnokogiriが正常に入っている
・gemを使ってnokogiriをインストールすると正常に入る
上記のような状況にも関わらず、Gemfileなるものでbundle install --path vendor/bundleを実行したところ、以下のQiitaの記事のような症状でbundleが正常に終了せず、結局環境構築を終了させることができませんでした。
https://qiita.com/yuki_uchida/items/3089d4e6bc9c8113c581
なので、どうにかこのエラーを解消して職場での開発にきちんと従事できるようになりたいです。
発生している問題・エラーメッセージ
Using rake 12.3.2 Using concurrent-ruby 1.1.5 Using aasm 5.0.1 Using abstract_type 0.0.7 Using i18n 1.6.0 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.2.2.1 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.3.0 Fetching nokogiri 1.8.5 Installing nokogiri 1.8.5 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/johndoe/Desktop/xxxxx/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.8.5/ext/nokogiri /Users/johndoe/.rbenv/versions/2.6.3/bin/ruby -I /Users/johndoe/.rbenv/versions/2.6.3/lib/ruby/site_ruby/2.6.0 -r ./siteconf20190805-942-1h1v7xa.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. 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/johndoe/.rbenv/versions/2.6.3/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/johndoe/Desktop/xxxxx/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.8.5/mkmf.log Permission denied @ rb_file_s_rename - (mkmf.log, /Users/johndoe/Desktop/xxxxx/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.8.5/mkmf.log) Gem files will remain installed in /Users/johndoe/Desktop/xxxxx/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.8.5 for inspection. Results logged to /Users/johndoe/Desktop/xxxxx/vendor/bundle/ruby/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.8.5/gem_make.out An error occurred while installing nokogiri (1.8.5), and Bundler cannot continue. **__Make sure that `gem install nokogiri -v '1.8.5' --source 'https://rubygems.org/'`__** succeeds before bundling. In Gemfile: activeadmin_addons was resolved to 1.7.0, which depends on xdan-datetimepicker-rails was resolved to 2.5.4, which depends on rails was resolved to 5.2.2.1, which depends on actioncable was resolved to 5.2.2.1, which depends on actionpack was resolved to 5.2.2.1, which depends on actionview was resolved to 5.2.2.1, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri
試したこと
https://qiita.com/ganta/items/3bb378726149a759d085
同様の症状の記事を参考に、
・brew install libxml2をしたのちにbundle config build.nokogiri --use-system-libraries --with-xml2-include=$(brew --prefix libxml2)/include/libxml2を実行
・bundle config build.nokogiri --use-system-librariesを実行したのちにbundle install
https://qiita.com/nipe0324/items/b12668806ab6be890208
同じ症状で別の解決策である↓を実行
・brew tap homebrew/dupes
brew install libxml2 libxslt libiconv
brew link libxml2 --force
brew link libxslt --force
gem install nokogiri -- --use-system-libraries --with-iconv-dir="$(brew --prefix libiconv)" --with-xml2-config="$(brew --prefix libxml2)/bin/xml2-config" --with-xslt-config="$(brew --prefix libxslt)/bin/xslt-config"
いずれも正しく動作しますが、いざbundle installを行うと上記のエラーが出てnokogiriのインストールに失敗してしまい、自分では手におえない状況です。
エラー中のgem install nokogiri -v '1.8.5' --source 'https://rubygems.org/'
も何度も試しましたが、
ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. current directory: /Users/xxxxx/.rbenv/gems/2.6.0/gems/nokogiri-1.8.5/ext/nokogiri /Users/xxxxx/.rbenv/versions/2.6.3/bin/ruby -I /Users/xxxxx/.rbenv/versions/2.6.3/lib/ruby/site_ruby/2.6.0 -r ./siteconf20190805-3672-jo1shz.rb extconf.rb 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 packaged libraries. Using mini_portile version 2.3.0 checking for iconv.h... yes checking for gzdopen() in -lz... yes checking for iconv... yes ************************************************************************ IMPORTANT NOTICE: Building Nokogiri with a packaged version of libxml2-2.9.8 with the following patches applied: - 0001-Revert-Do-not-URI-escape-in-server-side-includes.patch - 0002-Fix-nullptr-deref-with-XPath-logic-ops.patch - 0003-Fix-infinite-loop-in-LZMA-decompression.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. (略) To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/xxxxx/.rbenv/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.8.5/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/xxxxx/.rbenv/gems/2.6.0/gems/nokogiri-1.8.5 for inspection. Results logged to /Users/xxxxx/.rbenv/gems/2.6.0/extensions/x86_64-darwin-18/2.6.0-static/nokogiri-1.8.5/gem_make.out
と表示され、支持された通りmkmf.logをみてみたのですが、素人の私には皆目見当がつかない次第です。
補足情報(FW/ツールのバージョンなど)
ProductName: Mac OS X
ProductVersion: 10.14.6
なお、Xcodeがないと正しく動作しないという声もあったので導入し、command line toolsを正しく設定しましたが、状況は変わりませんでした。
以下rubyのバージョンなど参考になりそうなもの
$ which nokogiri
/Users/xxxxx/.rbenv/shims/nokogiri
(どのディレクトリで実行しても同じ表示)
$ ruby -version
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin18]
Traceback (most recent call last):
-e:1:in <main>': undefined local variable or method
rsion' for main:Object (NameError)
$ bundle -v
Bundler version 1.17.3
$ rails -v
Rails 5.2.3
(git cloneしたプロジェクト内でrails -vを実行すると
Could not find nokogiri-1.8.5 in any of the sources
Run bundle install
to install missing gems.
でrailsのバージョンは確認できません。)
なおlibxml2はwhichコマンドでは確認できませんでしたが、brew listでは確認できます。
環境構築で躓いたので、今の所1人だけDockerを用いて開発している状況です。
どうにかして他の人と一緒の環境で開発したいと切実に願っているので、お力を貸してください!
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/08/06 00:57