前提
- OS:
$ cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
- rubyはSCLリポジトリよりインストールされている
-
nokogiri-1.10.1がインストールされている(以下のコマンドでインストール)
$ gem install nokogiri -- --use-system-libraries
- railsプロジェクト内のGemfileを使用し
bundle installした場合Fetching nokogiri 1.8.1をしていることを確認 -
gem listを確認した場合nokogiri (1.10.1)となっていることを確認
エラー内容
$ export SECRET_KEY_BASE=`bundle exec rake secret`
bundler: failed to load command: rake (/home/centos/coin_stats/vendor/bundle/ruby/2.4.0/bin/rake)
Bundler::GemNotFound: Could not find nokogiri-1.8.1 in any of the sources
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/spec_set.rb:87:in `block in materialize'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `map!'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/spec_set.rb:81:in `materialize'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/definition.rb:170:in `specs'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/definition.rb:237:in `specs_for'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/definition.rb:226:in `requested_specs'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/runtime.rb:108:in `block in definition_method'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/runtime.rb:20:in `setup'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler.rb:107:in `setup'
/home/centos/.gem/ruby/gems/bundler-2.0.1/lib/bundler/setup.rb:20:in `<top (required)>'
/opt/rh/rh-ruby24/root/usr/share/rubygems/rubygems/core_ext/kernel_require.rb:55:in `require'
/opt/rh/
エラー解決
原因仮説
エラー文より、rakeコマンドがロード出来なかった模様。
なぜ出来なかったか?はおそらく nokogiri-1.8.1 をrakeコマンドが必要としているから。
前提の内容より、nokogiriは1.10.1がインストールされており、ここが問題となっていると見える。
仮説検証
実際にrakeコマンドを実行してみる。
$ /home/centos/coin_stats/vendor/bundle/ruby/2.4.0/bin/rake
Could not find nokogiri-1.8.1 in any of the sources
Run `bundle install` to install missing gems.
検証結果
検証した結果、やはりrakeコマンドはnokogiri-1.8.1を必要としている。
nokogiri-1.8.1を入れてあげられると問題が解決しそう。
解決方法
確認したところbundleで既にnokogiri-1.8.1が存在していたため、こちらを見るように調整してあげる。
$ vendor/bundle/ruby/2.4.0/gems/
actioncable-5.1.4/ mysql2-0.4.10/
actionmailer-5.1.4/ nio4r-2.2.0/
actionpack-5.1.4/ nokogiri-1.8.1/
$ gem uninstall nokogiri -v='1.10.1'
gem uninstall nokogiri -v='1.10.1'
You have requested to uninstall the gem:
nokogiri-1.10.1
loofah-2.2.3 depends on nokogiri (>= 1.5.9)
rails-dom-testing-2.0.3 depends on nokogiri (>= 1.6)
sprockets-3.7.2 depends on nokogiri (~> 1.3, development)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN] y
Remove executables:
nokogiri
in addition to the gem? [Yn] y
Removing nokogiri
Successfully uninstalled nokogiri-1.10.1
Note==============
依存関係のgemがあると警告されますが、無視してyを連打します。
==================
$ gem install nokogiri -v="1.8.1"
参考
gem uninstall