Mac Osをアップデートした際にbundle updateがエラーになる

#初めに
タイトルにもあるのですが、Mac Osをアプデートした際に``bundle update``を実行するとエラーが発生するように
なり、苦戦したので書きまとめておきます。

#エラー文

```
＄ bundle update

Fetching https://github.com/solidusio-contrib/solidus_i18n.git
NOTE: Gem::Specification#has_rdoc= is deprecated with no replacement. It will be removed on or after 2018-12-01.
Gem::Specification#has_rdoc= called from /Users/~/environment/~/vendor/bundle/ruby/2.5.0/bundler/gems/solidus_i18n-7d1552b32525/solidus_i18n.gemspec:24.
The dependency tzinfo-data (>= 0) will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependencyis 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/..........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies......
Using rake 12.3.2
Using concurrent-ruby 1.1.4 (was 1.1.3)
Using i18n 1.3.0 (was 1.1.1)
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.2
Using builder 3.2.3
Using erubi 1.8.0 (was 1.7.1)
Using mini_portile2 2.4.0 (was 2.3.0)
Fetching nokogiri 1.9.1 (was 1.8.5)
Installing nokogiri 1.9.1 (was 1.8.5) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/~/environment/~/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.9.1/ext/nokogiri
/Users/~/.rbenv/versions/2.5.1/bin/ruby -I /Users/~/.rbenv/versions/2.5.1/lib/ruby/site_ruby/2.5.0 -r
./siteconf20181229-51725-zmg84w.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/kanekoharuaki/.rbenv/versions/2.5.1/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/~/environment/~/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.9.1/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /Users/~/environment/~/vendor/bundle/ruby/2.5.0/gems/nokogiri-1.9.1 for inspection.
Results logged to
/Users/~/environment/~/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.9.1/gem_make.out

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

In Gemfile:
  solidus was resolved to 2.7.1, which depends on
    solidus_frontend was resolved to 2.7.1, which depends on
      canonical-rails was resolved to 0.2.4, which depends on
        rails was resolved to 5.2.2, which depends on
          actioncable was resolved to 5.2.2, which depends on
            actionpack was resolved to 5.2.2, which depends on
              actionview was resolved to 5.2.2, which depends on
                rails-dom-testing was resolved to 2.0.3, which depends on
                  nokogiri

```

このエラーが出た際にまずこのエラーが何なのか分からずにネットで調べようとしてしまっていました。

ですが、しっかりとログとして見るべき点がありました。

```
To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/~/environment/~/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-17/2.5.0-static/nokogiri-1.9.1/mkmf.log
```

まずはこのログを見ましょう。

#mkmf.logに書いてあったエラー

```
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools), missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
```

このようなエラーが出ていました。
これはXcodeをインストールされていないと出てくるエラーだと理解しました。
ですので、ターミナル上で以下のコマンドを入れましょう。

```
$ xcode-select --install
```

#mkmf.logの内容は変わったが何故かまだbundle update出来ない

その場合はこちらを実行しましょう。（*私はこちらで解決できました）

```
$ sudo open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg
```
![20181010_115952_fXGzD0.png](https://qiita-image-store.s3.amazonaws.com/0/319723/612928a2-1df4-8e7c-a194-e47be63060eb.png)

その結果、私は無事に``bundle　update``出来ました。