Could not find nokogiri-1.10.7 in any of the sources (Bundler::GemNotFound) が出た時の対処法

`rails generate`を実行したら以下のエラーが出た。

```sh
$ rails generate controller Welcome index
Traceback (most recent call last):
        22: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/bin/spring:49:in `<main>'
        21: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client.rb:30:in `run'
        20: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/command.rb:7:in `call'
        19: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/client/server.rb:9:in `call'
        18: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        17: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        16: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/server.rb:9:in `<top (required)>'
        15: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        14: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        13: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/commands.rb:4:in `<top (required)>'
        12: from /Library/Ruby/Gems/2.6.0/gems/spring-2.1.0/lib/spring/commands.rb:33:in `<module:Spring>'
        11: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
        10: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
         9: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/setup.rb:20:in `<top (required)>'
         8: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler.rb:107:in `setup'
         7: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/runtime.rb:20:in `setup'
         6: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/runtime.rb:108:in `block in definition_method'
         5: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/definition.rb:226:in `requested_specs'
         4: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/definition.rb:237:in `specs_for'
         3: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/definition.rb:170:in `specs'
         2: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `materialize'
         1: from /Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/spec_set.rb:85:in `map!'
/Users/maiamea/.rbenv/versions/2.6.3/lib/ruby/2.6.0/bundler/spec_set.rb:91:in `block in materialize': Could not find nokogiri-1.10.7 in any of the sources (Bundler::GemNotFound)
```


現在使っているRubyのバージョンを確認

```sh
$ ruby -v
ruby 2.6.3p62 (2019-04-16 revision 67580) [x86_64-darwin19]
$ rbenv versions
  system
  2.4.1
* 2.6.3 (set by /Users/maiamea/Documents/prog/rails/todo/.ruby-version)
  2.6.5
```

**rbenvでインストールしたRubyと、もともとMacにデフォルトで入っていたRubyのライブラリ（Gem）が混在していたためエラーになっていた。**

以下のコマンドで直った。

```sh
# Rubyのライブラリ（Gem）のインストール
$ bundle install

# インストールしたRubyライブラリのコマンドをrbenvで使えるようにする
$ rbenv rehash
```

対処後

```sh
$ rails generate controller Welcome index
Running via Spring preloader in process 80856
      create  app/controllers/welcome_controller.rb
       route  get 'welcome/index'
      invoke  erb
      create    app/views/welcome
      create    app/views/welcome/index.html.erb
      invoke  test_unit
      create    test/controllers/welcome_controller_test.rb
      invoke  helper
      create    app/helpers/welcome_helper.rb
      invoke    test_unit
      invoke  assets
      invoke    scss
      create      app/assets/stylesheets/welcome.scss
```

無事`rails generate`に成功した。