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

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

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

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

Q&A

解決済

2回答

2090閲覧

Rails nokogiriで引っかかってbundle installができない

chocolate_pie

総合スコア26

Ruby on Rails

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

0グッド

1クリップ

投稿2020/03/25 01:03

編集2020/03/25 05:36

前提・実現したいこと

いつもお世話になっています。

railsでbundle installしようとしたらnokogiriで引っかかって実行できません。
何個も記事を参照して試したのですがうまくいきません。
半日以上経っても解決していません…助けてください(泣)

【参考記事】
nokogiri を嫌いにならないで 〜インストール時のエラーを乗り越えろ〜
Rails 環境構築でのエラー ~ nokogiri(1.6.6.2) ~
nokogiriのinstallエラーの解消
nokogiriエラーが出ます。
nokogiri1.6.8がbundleできない(インストールはできる)
bundle install時の nokogiriエラー備忘録

発生している問題・エラーメッセージ

vagrant@vagrant:/vagrant/myapp$ bundle install --path vendor/bundle [DEPRECATED] The `--path` flag is deprecated because it relies on being remembered across bundler invocations, which bundler will no longer do in future versions. Instead please use `bundle config set path 'vendor/bundle'`, and stop using this flag 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/............ Using rake 12.3.2 Using concurrent-ruby 1.1.5 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.3 Using builder 3.2.3 Using erubi 1.8.0 Using mini_portile2 2.4.0 Fetching nokogiri 1.10.3 Installing nokogiri 1.10.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /vagrant/Web_Attendance/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.10.3/ext/nokogiri /usr/bin/ruby2.5 -r ./siteconf20200325-21706-ms07nl.rb extconf.rb --use-system-libraries checking if the C compiler accepts ... *** 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=/usr/bin/$(RUBY_BASE_NAME)2.5 --help --clean /usr/lib/ruby/2.5.0/mkmf.rb:456:in `try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `block in try_compile' from /usr/lib/ruby/2.5.0/mkmf.rb:521:in `with_werror' from /usr/lib/ruby/2.5.0/mkmf.rb:574:in `try_compile' from extconf.rb:138:in `nokogiri_try_compile' from extconf.rb:162:in `block in add_cflags' from /usr/lib/ruby/2.5.0/mkmf.rb:632:in `with_cflags' from extconf.rb:161:in `add_cflags' from extconf.rb:416:in `<main>' To see why this extension failed to compile, please check the mkmf.log which can be found here: /vagrant/Web_Attendance/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.3/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /vagrant/Web_Attendance/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.10.3 for inspection. Results logged to /vagrant/Web_Attendance/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/nokogiri-1.10.3/gem_make.out An error occurred while installing nokogiri (1.10.3), and Bundler cannot continue. Make sure that `gem install nokogiri -v '1.10.3' --source 'https://rubygems.org/'` succeeds before bundling. In Gemfile: rails was resolved to 5.2.3, which depends on actioncable was resolved to 5.2.3, which depends on actionpack was resolved to 5.2.3, which depends on actionview was resolved to 5.2.3, which depends on rails-dom-testing was resolved to 2.0.3, which depends on nokogiri

試したこと

①Gemfile.lockを一旦削除して再度bundle updateする→変わらず
②nokogiriをgem uninstall nokogiriしgem install nokogiriする→変わらず
③今とは違うブランチを切り替えて試してみる→変わらず
④gem install nokogiri -v '1.10.3' --source 'https://rubygems.org/実行→変わらず
⑤変わらず

$ bundle config build.nokogiri --use-system-libraries $ bundle install

⑥位置を変更したため注意されてしまいました(?)

vagrant@vagrant:/vagrant/Web_Attendance$ sudo bundle config build.nokogiri --with-xml2-config=/usr/local/opt/libxml2/bin/xml2-config --with-xslt-config=/usr/local/opt/libxslt/bin/xslt-config You are replacing the current global value of build.nokogiri, which is currently "--use-system-libraries"

補足情報(FW/ツールのバージョンなど)

ruby-v
ruby 2.5.7p206 (2019-10-01 revision 67816) [x86_64-linux-gnu]
Linux
ubuntu

rails -v
ビルドエラーで確認できませんでした

rubyやrailsのバージョンが関係あるのでしょうか?
→gemファイルのrubyバージョン 2.5.7
linuxのrubyバージョン 2.5.7 同じ
そこはクリアしていました

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

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

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

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

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

guest

回答2

0

自己解決

ホームディレクトリの「.bundle/config」内のBUNDLE_PATH: vendor/bundleを削除したらうまくいきました。
初心者でbundleの概念がよく分からず、gemを追加した際に参考サイトのコードを何も考えずにコピペしていたことが原因でした。

$ bundle install --path vendor/bundle←これを付けるとおかしくなるらしい

オプション、恐ろしいです…。次回からはbundle installだけを使っていきたいと思います。
nokogiriエラー卒業できてよかったです(泣)

投稿2020/03/25 06:55

chocolate_pie

総合スコア26

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

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

0

NokogiriJで必要なライブラリはインストールされてますか?
Nokogiriのビルドには、libxml2, libxslt, libiconvが必要なはずです。これらがないと、Nokogoriha使えません。。。
参考までに、Qiitaにあった記事を貼っておきます。
https://qiita.com/dskst/items/b1f073fcffeca3bc9fc6

投稿2020/03/25 03:48

s_eric

総合スコア184

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

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

chocolate_pie

2020/03/25 04:12

それを試そうとして、 $ brew tap homebrew/dupes -bash: brew: command not found こうなってしまってインストールができませんでした…
chocolate_pie

2020/03/25 04:15

$ xml2-config --version 2.9.4 $ xslt-config --version 1.1.29 $ iconv --version iconv (Ubuntu GLIBC 2.27-3ubuntu1) 2.27 Copyright (C) 2018 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Written by Ulrich Drepper. バージョン確認したら入っていました
s_eric

2020/03/25 04:46

> それを試そうとして、 $ brew tap homebrew/dupes -bash: brew: command not found こうなってしまってインストールができませんでした… 環境きちんと見ていませんでした。私が貼ったQiitaの記事、mac向けだったようです。すみません。
s_eric

2020/03/25 04:49

libxml2, libxslt, libiconvがインストールされているようなので、正直理由がつかめないのですが、Ruby2.5系、Vagrant、Ubuntu環境でのnokogiriの記事を見つけたので、貼っておきます。お役に立てず、申し訳ないです。 https://qiita.com/E-46/items/b1dc5807f8604952bf93
chocolate_pie

2020/03/25 05:35

それも実行済みです???? わざわざしらべていただきありがとうございます。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問