質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

658閲覧

nokogiriがインストールできない

eng

総合スコア7

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2018/06/12 15:30

編集2018/06/13 03:03

実現したいこと

  • nokogiriをインストールしたい

再現

rails sをする前にbundle installをすると

lang

1An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue. 2Make sure that `gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'` succeeds before 3bundling

と言われたのでgem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'を実行
すると

Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. current directory: /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180613-40944-1q1s8p6.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... no Using pkg-config gem version 1.3.1 checking for libiconv... no ----- libiconv is missing. Please locate mkmf.log to investigate how it is failing. ----- *** 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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/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 To see why this extension failed to compile, please check the mkmf.log which can be found here: /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Library/Ruby/Gems/2.3.0/gems/nokogiri-1.8.2 for inspection. Results logged to /Library/Ruby/Gems/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/gem_make.out

と出た。
ここから進まず困っています。

](https://qiita.com/kytiken/items/45da8f61775ec1cff3f8)

このあたりの対処方法を試したのですが解決できないです。

環境

macOS 10.13.5(17F77)

質問の仕方もよく分からないのですが、これで伝わりますでしょうか。
どなたか手助けしていただけると嬉しいです。

###追加
https://qiita.com/kytiken/items/45da8f61775ec1cff3f8 の`brew tap homebrew/dupes`
をすると

Error: homebrew/dupes was deprecated. This tap is now empty as all its formulae were migrated.

と出ます。
調べてみたのですがよく分からない状態です。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

motchang

2018/06/12 17:19

エラーメッセージを拝見したところ libiconv が見つからずにエラーになっているようです。 掲載されています、https://qiita.com/kytiken/items/45da8f61775ec1cff3f8 こちらの記事の操作をしたあとのメッセージも添付していただけますか?
eng

2018/06/13 03:04

ありがとうございます。試してみたのですが新しいエラーが出てきました。調べてみたのですが解決できていない状態です。
eng

2018/06/13 03:07

ちなみにbrew tapをするとhomebrew/coreのみ表示されます
guest

回答2

0

ベストアンサー

お使いの MacOS X High Sierra で Apple 公式の libiconv をインストールする方法は下記のようです。

bash

1xcode-select --install

ref: https://stackoverflow.com/questions/40038953/how-to-install-nokogiri-on-mac-os-sierra-10-12

こちらをお試しの上、再度 bundle install をしてみてはいかがでしょうか?

投稿2018/06/13 03:15

motchang

総合スコア101

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

eng

2018/06/13 03:46 編集

``` xcode-select: error: command line tools are already installed, use "Software Update" to install updates ``` と出てきます。 この状態で bundle install をすると ``` Fetching gem metadata from https://rubygems.org/.............. Using rake 12.3.1 Using concurrent-ruby 1.0.5 Using i18n 1.0.1 Using minitest 5.11.3 Using thread_safe 0.3.6 Using tzinfo 1.2.5 Using activesupport 5.1.6 Using builder 3.2.3 Using erubi 1.7.1 Using mini_portile2 2.3.0 Fetching nokogiri 1.8.2 Installing nokogiri 1.8.2 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/name/app-name/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2/ext/nokogiri /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby -r ./siteconf20180613-34220-1bkx9qu.rb extconf.rb --use-system-libraries --with-iconv-dir=/usr/local/opt/libiconv 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=/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/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/name/app-name/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/name/app-name/vendor/bundle/ruby/2.3.0/gems/nokogiri-1.8.2 for inspection. Results logged to /Users/name/app-name/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/nokogiri-1.8.2/gem_make.out An error occurred while installing nokogiri (1.8.2), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.8.2' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.1.6, which depends on actioncable was resolved to 5.1.6, which depends on actionpack was resolved to 5.1.6, which depends on actionview was resolved to 5.1.6, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri ``` 先ほどlibiconvもインストールできていない状態です、、、
eng

2018/06/13 03:52 編集

ここでもbrew tapをしたのですがやはりhomebrew/coreのみ表示されます、、 brew update はしてみましたが変化なしです。
motchang

2018/06/13 03:53

こんどは libxml2 が見つからないようですね。 > pkg-config could not be used to find libxml-2.0 先ほどの StackOverflow の一つしたの回答に解決方法が書いてありましたね。 https://stackoverflow.com/a/41499183/1696137 ```sh brew install libxml2 ``` ```sh bundle config build.nokogiri --use-system-libraries \ --with-xml2-include=$(brew --prefix libxml2)/include/libxml2 bundle install ``` こちらをお試しください。 それと brew tap は homebrew の主流でないライブラリなどを利用する場合に使うコマンドなので、通常であれば brew tap の出力は homebrew/core のみです。
eng

2018/06/13 04:02

なるほど、ありがとうございます! おかげさまでnokogiriのエラーは解決しました! 新しいエラーが出たので取り組みます。 ご親切にありがとうございました!
guest

0

本件は解決しました。
ありがとうございました!

投稿2018/06/13 04:02

eng

総合スコア7

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問