brew doctorで出たエラーの対処方法

自分の環境で出たエラーの対処方法
原因は色々あるので個々に記述する。

Warning: The following directories do not exist:

原因: フォルダが存在しない

対処法

下記にある sudo から始まるコマンドを実行する

エラー全文

Warning: The following directories do not exist:
/usr/local/sbin

You should create these directories and change their ownership to your account.
  sudo mkdir -p /usr/local/sbin
  sudo chown -R $(whoami) /usr/local/sbin

Warning: Unbrewed dylibs were found in /usr/local/lib.

原因: 不要なファイルがある

対処法

不要ファイルを消す。
Unexpected dylibs に出力されてるファイルを削除

rm -rf [file path]

エラー全文

Warning: Unbrewed dylibs were found in /usr/local/lib.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected dylibs:
  /usr/local/lib/libwkhtmltox.0.12.4.dylib

Warning: Unbrewed header files were found in /usr/local/include.

原因: 不要なファイルがある

対処法

Unexpected header files に出力されてるファイルを削除

rm -rf [file path]

エラー全文

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/wkhtmltox/image.h
  /usr/local/include/wkhtmltox/pdf.h

Warning: You have unlinked kegs in your Cellar

原因: リンクが無い

対処法

Run brew link on these のモジュールでリンク作る。

brew link [module name]

リンク作るときにエラーが出たら

フォルダがあるか確認して、なければ作り権限を付与する

- 対処法
フォルダの権限確認、フォルダなければ作る

sudo mkdir /usr/local/Frameworks
sudo chown $(whoami) /usr/local/Frameworks

- エラー全文
❯ brew link python
Linking /usr/local/Cellar/python/3.7.1... Error: Permission denied @ dir_s_mkdir - /usr/local/Frameworks

エラー全文

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:
  python

Warning: Broken symlinks were found. Remove them with brew prune

原因: 削除漏れ

対処法

コマンド実行して削除

brew prune

エラー全文

Warning: Broken symlinks were found. Remove them with `brew prune`:
  /usr/local/bin/docker-credential-osxkeychain.backup
  /usr/local/bin/hyperkit.backup
  /usr/local/bin/notary.backup
  /usr/local/bin/vpnkit.backup