brew doctorでWarningが出た時の解決方法 (2021.7)

##環境
iMac (2017)
macOS Big Sir ver 11.4

##状況
HomebrewのHP（https://brew.sh/index_ja） からコピーした以下コマンドでHomebrewをインストールして、

```Bash:terminal
% /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
```

以下コマンドを用いてインストールされたHomebrewが最新版であるかを判定した。

```Bash:terminal
% brew doctor
```
その結果、以下の４つのエラーが発生。

```:terminal
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

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/libtcl8.6.dylib
  /usr/local/lib/libtk8.6.dylib

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/fakemysql.h
  /usr/local/include/fakepq.h
  /usr/local/include/fakesql.h
  /usr/local/include/itcl.h
  /usr/local/include/itcl2TclOO.h
  /usr/local/include/itclDecls.h
  /usr/local/include/itclInt.h
  /usr/local/include/itclIntDecls.h
  /usr/local/include/itclMigrate2TclCore.h
  /usr/local/include/itclTclIntStubsFcn.h
  /usr/local/include/mysqlStubs.h
  /usr/local/include/odbcStubs.h
  /usr/local/include/pqStubs.h
  /usr/local/include/tcl.h
  /usr/local/include/tclDecls.h
  /usr/local/include/tclOO.h
  /usr/local/include/tclOODecls.h
  /usr/local/include/tclPlatDecls.h
  /usr/local/include/tclThread.h
  /usr/local/include/tclTomMath.h
  /usr/local/include/tclTomMathDecls.h
  /usr/local/include/tdbc.h
  /usr/local/include/tdbcDecls.h
  /usr/local/include/tdbcInt.h
  /usr/local/include/tk.h
  /usr/local/include/tkDecls.h
  /usr/local/include/tkPlatDecls.h

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

Unexpected '.pc' files:
  /usr/local/lib/pkgconfig/tcl.pc
  /usr/local/lib/pkgconfig/tk.pc

Warning: Unbrewed static libraries 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 static libraries:
  /usr/local/lib/libtclstub8.6.a
  /usr/local/lib/libtkstub8.6.a
```

###まずは以下の初めのエラーから解決を試みた。

```:terminal
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/libtcl8.6.dylib
  /usr/local/lib/libtk8.6.dylib
```
予期しない.dylibが見つかったとのことなので、中身を確認してみる。

```:terminal
% ls -l /usr/local/lib/
total 5136
drwxr-xr-x   9 root    wheel      288  3 30  2020 Tktable2.10
drwxr-xr-x   9 root    wheel      288  3 30  2020 itcl4.0.5
-r-xr-xr-x   1 root    wheel  1441840  3 30  2020 libtcl8.6.dylib
-rwxr-xr-x@  1 root    wheel     4696  3 23  2017 libtclstub8.6.a
-r-xr-xr-x   1 root    wheel  1147376  3 30  2020 libtk8.6.dylib
-rwxr-xr-x@  1 root    wheel     3496  7  3  2017 libtkstub8.6.a
drwxrwxr-x   4 shiori  admin      128  7  5  2017 pkgconfig
drwxr-xr-x   4 root    wheel      128  3 30  2020 sqlite3.13.0
drwxr-xr-x   5 root    wheel      160  3 23  2017 tcl8
drwxr-xr-x  17 root    wheel      544  3 23  2017 tcl8.6
-rw-r--r--   1 root    wheel     7957  3 23  2017 tclConfig.sh
-rw-r--r--   1 root    wheel      773  3 23  2017 tclooConfig.sh
drwxr-xr-x   7 root    wheel      224  3 30  2020 tdbc1.0.4
drwxr-xr-x   5 root    wheel      160  3 30  2020 tdbcmysql1.0.4
drwxr-xr-x   5 root    wheel      160  3 30  2020 tdbcodbc1.0.4
drwxr-xr-x   5 root    wheel      160  3 30  2020 tdbcpostgres1.0.4
drwxr-xr-x   5 root    wheel      160  3 30  2020 thread2.8.0
drwxr-xr-x  40 root    wheel     1280  7  5  2017 tk8.6
-rw-r--r--   1 root    wheel     4344  7  3  2017 tkConfig.sh
```

確かにエラー文に書かれた.dylibがあったので、こちらを削除してみる。

```:terminal
% rm /usr/local/lib/libtcl8.6.dylib
override r-xr-xr-x  root/wheel for /usr/local/lib/libtcl8.6.dylib? y
% rm /usr/local/lib/libtk8.6.dylib
override r-xr-xr-x  root/wheel for /usr/local/lib/libtk8.6.dylib? y
```
###次に以下の２つ目のエラーの解決を試みる。

```:terminal
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/fakemysql.h
  /usr/local/include/fakepq.h
  /usr/local/include/fakesql.h
  /usr/local/include/itcl.h
  /usr/local/include/itcl2TclOO.h
  /usr/local/include/itclDecls.h
  /usr/local/include/itclInt.h
  /usr/local/include/itclIntDecls.h
  /usr/local/include/itclMigrate2TclCore.h
  /usr/local/include/itclTclIntStubsFcn.h
  /usr/local/include/mysqlStubs.h
  /usr/local/include/odbcStubs.h
  /usr/local/include/pqStubs.h
  /usr/local/include/tcl.h
  /usr/local/include/tclDecls.h
  /usr/local/include/tclOO.h
  /usr/local/include/tclOODecls.h
  /usr/local/include/tclPlatDecls.h
  /usr/local/include/tclThread.h
  /usr/local/include/tclTomMath.h
  /usr/local/include/tclTomMathDecls.h
  /usr/local/include/tdbc.h
  /usr/local/include/tdbcDecls.h
  /usr/local/include/tdbcInt.h
  /usr/local/include/tk.h
  /usr/local/include/tkDecls.h
  /usr/local/include/tkPlatDecls.h
```

警告文にあるヘッダファイルとは、「（主にC言語系における）ソースコードの一部を別に分けたファイル」のことで、.hという拡張子は「C言語のヘッダファイルに付くことが多い拡張子」だそうです。これも警告文に"may need to be deleted."とあるので消します。


```:terminal
% rm /usr/local/include/fakemysql.h
override rw-r--r--  root/wheel for /usr/local/include/fakemysql.h? y
% rm /usr/local/include/fakepq.h                            
override r--r--r--  root/wheel for /usr/local/include/fakepq.h? y
% rm /usr/local/include/fakesql.h
override r--r--r--  root/wheel for /usr/local/include/fakesql.h? y
% rm /usr/local/include/itcl.h
override rw-r--r--  root/wheel for /usr/local/include/itcl.h? y
% rm /usr/local/include/itcl2TclOO.h
override rw-r--r--  root/wheel for /usr/local/include/itcl2TclOO.h? y
% rm /usr/local/include/itclDecls.h
override rw-r--r--  root/wheel for /usr/local/include/itclDecls.h? y
% rm /usr/local/include/itclInt.h
override rw-r--r--  root/wheel for /usr/local/include/itclInt.h? y
% rm /usr/local/include/itclIntDecls.h
override rw-r--r--  root/wheel for /usr/local/include/itclIntDecls.h? y
% rm /usr/local/include/itclMigrate2TclCore.h
override rw-r--r--  root/wheel for /usr/local/include/itclMigrate2TclCore.h? y
% rm /usr/local/include/itclTclIntStubsFcn.h
override rw-r--r--  root/wheel for /usr/local/include/itclTclIntStubsFcn.h? y
% rm /usr/local/include/mysqlStubs.h
override rw-r--r--  root/wheel for /usr/local/include/mysqlStubs.h? y
% rm /usr/local/include/odbcStubs.h
override r--r--r--  root/wheel for /usr/local/include/odbcStubs.h? y
% rm /usr/local/include/pqStubs.h
override r--r--r--  root/wheel for /usr/local/include/pqStubs.h? y
% rm /usr/local/include/tcl.h 
override rw-r--r--  root/wheel for /usr/local/include/tcl.h? y
% rm /usr/local/include/tclDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tclDecls.h? y
% rm /usr/local/include/tclOO.h
override rw-r--r--  root/wheel for /usr/local/include/tclOO.h? y
% rm /usr/local/include/tclOODecls.h
override rw-r--r--  root/wheel for /usr/local/include/tclOODecls.h? y
% rm /usr/local/include/tclPlatDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tclPlatDecls.h? y
% rm /usr/local/include/tclThread.h
override rw-r--r--  root/wheel for /usr/local/include/tclThread.h? y
% rm /usr/local/include/tclTomMath.h
override rw-r--r--  root/wheel for /usr/local/include/tclTomMath.h? y
% rm /usr/local/include/tclTomMathDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tclTomMathDecls.h? y
% rm /usr/local/include/tdbc.h
override rw-r--r--  root/wheel for /usr/local/include/tdbc.h? y
% rm /usr/local/include/tdbcDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tdbcDecls.h? y
% rm /usr/local/include/tdbcInt.h
override rw-r--r--  root/wheel for /usr/local/include/tdbcInt.h? y
% rm /usr/local/include/tk.h
override rw-r--r--  root/wheel for /usr/local/include/tk.h? y
% rm /usr/local/include/tkDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tkDecls.h? y
% rm /usr/local/include/tkPlatDecls.h
override rw-r--r--  root/wheel for /usr/local/include/tkPlatDecls.h? y
```

###次に、以下の3つ目のエラーの解決を試みます。

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

Unexpected '.pc' files:
  /usr/local/lib/pkgconfig/tcl.pc
  /usr/local/lib/pkgconfig/tk.pc
```
これも警告文に"may need to be deleted."とあるので消します。

```:terminal
% rm /usr/local/lib/pkgconfig/tcl.pc
override rw-r--r--  root/wheel for /usr/local/lib/pkgconfig/tcl.pc? y
minabe@MinabeMac ~ % rm /usr/local/lib/pkgconfig/tk.pc
override rw-r--r--  root/wheel for /usr/local/lib/pkgconfig/tk.pc? y
```

###次に、以下の4つ目のエラーの解決を試みます。

```:terminal
Warning: Unbrewed static libraries 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 static libraries:
  /usr/local/lib/libtclstub8.6.a
  /usr/local/lib/libtkstub8.6.a
```
これも警告文に"may need to be deleted."とあるので消します。

```:terminal
% rm /usr/local/lib/libtclstub8.6.a
override rwxr-xr-x  root/wheel for /usr/local/lib/libtclstub8.6.a? y
% rm /usr/local/lib/libtkstub8.6.a
override rwxr-xr-x  root/wheel for /usr/local/lib/libtkstub8.6.a? y
```

###最後にbrew doctorでエラーが出ないことを確認。
```:terminal
% brew doctor                       
Your system is ready to brew.
```

とりあえず消せばよかったのね。解決。

以上です。

##参考
以下の記事を参考にしました。
「Homebrewの問題を確認する"brew doctor"コマンドとWarning対策集[macOS]」
https://ichibariki.com/entry/2018/03/24/213524#Warning-Unbrewed-header-files-were-found-in-usrlocalinclude