Homebrewのアップデート時に出た5つのWarningと解決方法

久しぶりに`brew update`をかけようとしたらエラーが出てアップデートできなかったので、`brew doctor`で出たWarningと解決手順をメモ。
# 環境
MacBook Pro (Retina, 13-inch、Early 2015)
OS X El Capitan バージョン10.11.6（15G1004）
XQuartz 2.7.8
Xcode Version 8.0 (8A218a)

# ５つのWarningが出たよ
`brew doctor`を叩いて出たWarningは以下の5つ。

```
Warning: Your XQuartz (2.7.8) is outdated
Please install XQuartz 2.7.9:
  https://xquartz.macosforge.org

Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    mono
 
Warning: You have Xcode 8 installed without the CLT;
this causes certain builds to fail on OS X El Capitan (10.11).
Please install the CLT via:
  sudo xcode-select --install

Warning: Broken symlinks were found. Remove them with `brew prune`:
    /usr/local/share/man/man8/prlexec.8
 
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.
 
Binaries provided by keg-only formulae may override system binaries
with other strange results.
 
You may wish to `brew unlink` these brews:
    openssl
```


順番に解消していく。

# 解決方法

## 1.XQuartzのアップデート

```
Warning: Your XQuartz (2.7.8) is outdated
Please install XQuartz 2.7.9:
https://xquartz.macosforge.org
```

XQuartzが古い。[公式サイト](https://xquartz.macosforge.org/)から最新版をインストールする。

## 2.monoのシンボリックリンクを貼り直す

```
Warning: You have unlinked kegs in your Cellar
Leaving kegs unlinked can lead to build-trouble and cause brews that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
    mono
```

monoのシンボリックリンクが切れてる。
`brew link mono`でシンボリックリンクを貼る。

```
Error: Could not symlink bin/al
Target /usr/local/bin/al
already exists. You may want to remove it:
  rm '/usr/local/bin/al'
```

こんなErrorが出たら`overwrite`オプションつけて強制的に上書きする。
`$ brew link --overwrite mono`

## 3.CLTのアップデート

```
Warning: You have Xcode 8 installed without the CLT;
this causes certain builds to fail on OS X El Capitan (10.11).
Please install the CLT via:
  sudo xcode-select --install
```

XcodeのCLT（Command Line Tools）が古いのでアップデートする。

## 4.デッドシンボリックリンクを削除
```
Warning: Broken symlinks were found. Remove them with `brew prune`:
    /usr/local/share/man/man8/prlexec.8
```

これは単純に書かれてるコマンド叩いたら権限がないとのエラーが出た。

```
$ brew prune /usr/local/share/man/man8/prlexec.8
Error: Permission denied - /usr/local/share/man/man8/prlexec.8
```

親フォルダの所有者を実行ユーザーにして権限を付与。
`$ sudo chown -R unsoluble_sugar /usr/local/share/man/man8`
再度`brew prune`を叩いて解決。

```
$ brew prune /usr/local/share/man/man8/prlexec.8
Pruned 1 symbolic links and 5 directories from /usr/local
```

## 5.opensslのシンボリックリンクを貼り直す

```
Warning: Some keg-only formula are linked into the Cellar.
Linking a keg-only formula, such as gettext, into the cellar with
`brew link <formula>` will cause other formulae to detect them during
the `./configure` step. This may cause problems when compiling those
other formulae.
 
Binaries provided by keg-only formulae may override system binaries
with other strange results.

You may wish to `brew unlink` these brews:
    openssl
```

opensslのシンボリックリンクを削除。
`$ brew unlink openssl`
貼り直す。
`$ brew install openssl`
これだけ。

# Homebrewをアップデート
`brew doctor`で問題が解消されていることを確認。

```
$ brew doctor
Your system is ready to brew.
```

`brew update`でHomebrewをアップデート。

```
$ brew update
Updated 1 tap (homebrew/core).
==> Updated Formulae
ace                            gnome-builder                  gucharmap
clutter-gtk                    gnome-icon-theme               mongodb
evince                         gsettings-desktop-schemas      neofetch
gedit                          gtk+3                          nmap
git-archive-all                gtkmm3
```

おしまい。