MacのソフトウェアをHomebrewで管理していて起きる問題の、最も多い原因は自動アップデートによるものだと感じます。問題の事例とその防止策である自動アップデートを止める方法をお伝えします。結論から知りたい方は、目次から「対処策」に飛んでください。これをしない場合、どんな目に合うかは全部をお読みになればご理解頂けます。
急にApacheが起動しなくなる
以下のようなエラーが出てApacheが起動しなくなりました。
| 1 2 3 4 | $ brew services start httpd Bootstrap failed: 5: Input/output error Try re-running the command as root for richer errors. Error: Failure while executing; `/bin/launchctl bootstrap gui/501 /Users/xxxxx/Library/LaunchAgents/homebrew.mxcl.httpd.plist` exited with 5. | 
詳しく知るためにhttpdコマンドも実行してみます。
| 1 2 | $ httpd httpd: Syntax error on line 182 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/lib/httpd/modules/libphp7.3.33.so into server: dlopen(/opt/homebrew/lib/httpd/modules/libphp7.3.33.so, 0x000A): Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib\n  Referenced from: <D9B85121-5801-3A5D-9239-B64DFE2A079F> /opt/homebrew/Cellar/httpd/2.4.57/lib/httpd/modules/libphp7.3.33.so\n  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib' (no such file), '/usr/local/lib/libicui18n.72.dylib' (no such file), '/usr/lib/libicui18n.72.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/73.2/lib/libicui18n.72.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/73.2/lib/libicui18n.72.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/73.2/lib/libicui18n.72.dylib' (no such file), '/usr/local/lib/libicui18n.72.dylib' (no such file), '/usr/lib/libicui18n.72.dylib' (no such file, not in dyld cache) | 
いろんなことが書かれていますが、一番目につくのはこれ
| 1 | httpd: Syntax error on line 182 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/lib/httpd/modules/libphp7.3.33.so into server: dlopen(/opt/homebrew/lib/httpd/modules/libphp7.3.33.so, 0x000A) | 
/opt/homebrew/lib/httpd/modules/ にあったはずの、 libphp7.3.33.so が消えてるんです。
なんでだろうとかなり考えました。Symlinkが何かのきっかけで消えてしまったのだろうかなどと。
しかし、最近やったことを思い出してようやく原因と思しきことに至りました。
ちょっと前に、JavaをHomebrewでインストールしたんですよね。その際に、Updateが走って、色々なソフトウェアがアップデートされていました。
あぁ、Apacheもバージョンが上がったのかな、と思ってFormulaを確認してみました。
| 1 2 | $ cd /opt/homebrew/Library/Taps/homebrew/homebrew-core/Formula $ git log httpd.rb | 
gitのログを確認しても、最近の更新は無いんですよね。なんでだろうと思いました。
Javaをインストールした時のターミナルの出力をもう一度確認したところ、以下の部分を見つけました。
| 1 2 3 | ==> Checking for dependents of upgraded formulae... ==> Reinstalling 1 dependent with broken linkage from source: httpd | 
これ、調べたり、考えてみたところ、アップデートされたソフトウェアの依存元からの結合が壊れた場合、依存元を再インストールするということのようです。
以下の記事(英語)で知りましたが「dependency」は「依存先」であるのに対し、「dependent」は「依存元」です。
What does dependency/dependant mean?
Apacheが依存しているソフトウェアがアップデートされた場合、Apachのバイナリーの中に依存先のバージョン番号などがビルド時に書きこまれていたら、再ビルドしないと動きません。なので、再インストールが走ったということのようです。この辺は後でわかったことですが。このような依存関係まで把握できるのはHomebrew賢いなーと思いました。もしかしたらこの辺もFormulaに記載しているのかもしれません。
話が外れましたが、消えてしまった libphp7.3.33.soですがこれは、PHPBrewでPHPをインストールした際にこのディレクトリに配置されました。
つまり、HomebrewでApacheを、PHPBrewでPHPを管理している場合、Apacheを再インストールしたら動かなくなってしまうということです。
もしかしたら、PHPもHomebrewで管理している場合はどうなるのかわかりませんが、とにかく、Apacheの再インストールはよく準備した上でするべきだということです。
PHPから呼んでるもののパスも変わっちゃってる
libphp7.3.33.soはPHPbrewが生成した場所には残っているので、それを消失してしまった場所に戻しました。
| 1 | $ cp ~/.phpbrew/build/php-7.3.33/libs/libphp7.3.33.so /opt/homebrew/Cellar/httpd/2.4.57/lib/httpd/modules/ | 
ちなみに、Homebrewの仕組み上、
/opt/homebrew/lib/httpd/modules/
と
/opt/homebrew/Cellar/httpd/2.4.57/lib/httpd/modules/
に必要なのですが、前者は後者のSymlinkなので、後者にとりあえず配置しました。
すると、前者にもいつのまにか当該ファイルのSymlinkが生成されていました。ただ、どのタイミングでSymlinkがはられるのかはよくわかりません。きちんと前者にこのファイルが配置されない場合は、なんらかの手段でSymlinkを生成しましょう。それか、Symlinkにこだわらずこのファイルをコピーしてきてしまってもいいかもしれません。
しかし、この状態でApacheを起動すると、また全く同じエラーが発生しました。libphp7.3.33.soはあるはずなんですけどね。
とりあえず、次のエラーに注目しました。
| 1 | Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib\n  Referenced from: <D9B85121-5801-3A5D-9239-B64DFE2A079F> /opt/homebrew/Cellar/httpd/2.4.57/lib/httpd/modules/libphp7.3.33.so\n  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.72.dylib' (no such file), | 
libphp7.3.33.soから参照しているファイルが無いということです。当該ファイルがあるはずのディレクトリを調べてみたところ、
| 1 2 3 4 5 | $ ls /opt/homebrew/opt/icu4c/lib/ icu			libicudata.dylib	libicui18n.dylib	libicuio.dylib		libicutest.dylib	libicutu.dylib		libicuuc.dylib libicudata.73.2.dylib	libicui18n.73.2.dylib	libicuio.73.2.dylib	libicutest.73.2.dylib	libicutu.73.2.dylib	libicuuc.73.2.dylib	pkgconfig libicudata.73.dylib	libicui18n.73.dylib	libicuio.73.dylib	libicutest.73.dylib	libicutu.73.dylib	libicuuc.73.dylib libicudata.a		libicui18n.a		libicuio.a		libicutest.a		libicutu.a		libicuuc.a | 
あー、ファイル名に付与されたバージョン番号がエラーに表示されたものと違うんですよね。
このicu4cというソフトウェアは、前述したJavaをインストールした際にしっかりアップデートされていました。PHPもHomebrewで管理していたら、前述した「dependent(依存元)」に相当するので、PHPもこのタイミングで再インストールされていたかもしれません。しかしPHPbrewで管理しているのでそういうわけにはいきません。
もしかしたら、PHPをPHPbrewで再インストールしたら新しいファイル名の方を参照してくれるかもしれませんが、PHPの再インストールは以下に記載したとおり面倒なので避けました。

なので、以下の方法で元のバージョンに戻すことにしました。

73.2をアンインストールしてからやったはずなのですが、なぜか両方出てきてしまいます。
| 1 2 | $ brew list icu4c --versions icu4c 73.2 72.1 | 
仕方ないので、以下をします。
| 1 | $ brew uninstall --ignore-dependencies icu4c | 
両バージョン消えてしまいそうなものですが、以下の記事によると最新の方だけ消してくれます。実際にこの後、72.1のみになりました。
【Homebrew】brew upgradeしたらPHP7.4が使えなくなった
まだこれだけでは足りなくて、以下をすることで、Symlinkを適切な場所にはります。
| 1 | $ brew link icu4c --force | 
これで再びApacheの起動を試みると、エラーの内容が少し変わりました。
| 1 | httpd: Syntax error on line 182 of /opt/homebrew/etc/httpd/httpd.conf: Cannot load /opt/homebrew/lib/httpd/modules/libphp7.3.33.so into server: dlopen(/opt/homebrew/lib/httpd/modules/libphp7.3.33.so, 0x000A): Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib\n  Referenced from: <D485EE1D-B254-3745-8D28-85993CC37B84> /opt/homebrew/Cellar/libxml2/2.11.4_1/lib/libxml2.2.dylib\n  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file), '/usr/local/lib/libicui18n.73.dylib' (no such file), '/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicui18n.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicui18n.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicui18n.73.dylib' (no such file), '/usr/local/lib/libicui18n.73.dylib' (no such file), '/usr/lib/libicui18n.73.dylib' (no such file, not in dyld cache) | 
注目すべきは、
| 1 | Library not loaded: /opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib\n  Referenced from: <D485EE1D-B254-3745-8D28-85993CC37B84> /opt/homebrew/Cellar/libxml2/2.11.4_1/lib/libxml2.2.dylib\n  Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicui18n.73.dylib' (no such file) | 
libxml2.2.dylibというファイルから、先ほどのicu4cに属するファイルを呼んでいるのですが、前のバージョンに戻す前の73系のファイル名で呼んでいるんですよね。つまり、libxml2もJavaインストール時にアップグレードされたんですけど、その時バイナリ内にicu4cのパスが書き込まれたということです。
というか、icu4cを戻すときに、「dependent(依存元)」 チェックに引っかかって再インストールされるべきものな気がするのですが。dependency(依存先)はたくさん再インストールされていたんですがね。最新化以外の時は、dependentチェックは走らないのですかね。それとも、dependentチェックはApacheくらいメジャーじゃないと設定されていないのですかね。
なので、libxml2は再インストールするだけで書き込まれたパスは直るかもしれませんが、なんとなくこちらもJavaインストール前のバージョンに戻すことにしました。
すると、Apacheは無事に起動しました。
対処策
これまで、あえて最新バージョン以外をインストールする場合にその都度に以下のようにつけていた
| 1 | $ HOMEBREW_NO_AUTO_UPDATE=1 brew install xxxxx | 
HOMEBREW_NO_AUTO_UPDATE というオプションですが、これはもうシェルの環境変数に指定してしまうべきです。
よく考えると、何かをインストールする時に、自動的にそれ以外のソフトウェアも全部アップデートしてしまうというのは暴力的です。今まで、暴力的すぎて現実味が無くて、問題視していなかったのですが、今回の問題が起きてしっかりわかりました。
シェルの設定ファイルに以下を追記します。私の場合は .zprofile です。
| 1 | export HOMEBREW_NO_AUTO_UPDATE=1 | 
利用中のターミナルのセッションでこの変更を反映させるためには、
| 1 | $ source .zprofile | 
を実行します。
これを設定しておけば、前述した問題は発生していませんでした。
なぜ自動的にアップデート「する」のがデフォルトなのか理解に苦しみます。どんなソフトウェアでも、アップデートする場合は、「アップデートしますか?」って聞いてくれますよね。
ちなみに、先ほども紹介した以下の記事で説明した、API経由でインストールしないための環境変数も併せてここで設定しました。

なので、追記するのはこうなります。
| 1 2 | export HOMEBREW_NO_AUTO_UPDATE=1 export HOMEBREW_NO_INSTALL_FROM_API=1 | 
なお、.zprofileなどの設定ファイルを頻繁に編集するようであれば、これらをGitで管理するのがおすすめです。そのためにdotfilesというディレクトリを作って管理する方法を以下で説明しています。

あと、zshの設定をどのファイルに記載するべきかにいくつか考え方があります。それについて以下で考えてみました。

PHPbrewがおかしい
上記の対応策を設定した後の話です。
PHPbrewで設定を確認しようと思ったら、以下のようなエラーが。
| 1 2 3 4 5 | % phpbrew -v dyld[81834]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuio.73.dylib   Referenced from: <99BDB143-515C-3FCA-A142-FBB6544A56CE> /opt/homebrew/Cellar/php@8.1/8.1.20_2/bin/php   Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/usr/local/lib/libicuio.73.dylib' (no such file), '/usr/lib/libicuio.73.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/usr/local/lib/libicuio.73.dylib' (no such file), '/usr/lib/libicuio.73.dylib' (no such file, not in dyld cache) | 
PHPbrewって、Homebrewでインストールした(PHPbrewで管理していない)PHPを呼んでいるんですよね。そのPHPが前述したicu4cやlibxml2と同じく、Javaインストール時にアップデートされていました。そのバイナリーの中に、icu4cのアップデートされたファイル名が入っていましたが、先ほどicu4cのバージョンを戻したので、ファイルを見つけれれないということです。
ここまできて、icu4cのバージョンを戻すという対処策はあまり良い手段ではなかったということに気がつきました。Homebrewで管理しているソフトウェアがアップデートされ、PHPbrewで管理しているPHPが動かない事象が発生した場合、もう一度PHPbrewでそのPHPを再インストール(コンパイル)した方が手数が少なくてすみそうです。Homebrewで管理しているソフトウェアのバージョンを戻すと、それの依存元になっているHomebrewで管理しているソフトウェア(いくつあるかわからない)との依存関係が崩れるためです。
しかし、今回はもうicu4cを戻してしまったし、それの依存元であるlibxml2も再インストールしてしまったので、PHPも再インストールすることにします。
PHPをアンインストールします。
| 1 2 3 4 5 6 7 | $ brew uninstall --ignore-dependencies php@8.1 Uninstalling /opt/homebrew/Cellar/php@8.1/8.1.20_2... (515 files, 81.8MB) Warning: The following may be php@8.1 configuration files and have not been removed! If desired, remove them manually with `rm -rf`:   /opt/homebrew/etc/php $ rm -rf /opt/homebrew/etc/php | 
インストールします。
| 1 | $ brew install php@8.1 | 
しかし、以下のようなWarningが出て適切に完了しません。
| 1 2 3 4 5 6 | dyld[87411]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuio.73.dylib   Referenced from: <78B59EEE-F381-3C30-BE33-663851CEB9A1> /opt/homebrew/Cellar/php@8.1/8.1.20_1/bin/php   Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuio.73.dylib' (no such file), '/usr/local/lib/libicuio.73.dylib' (no such file), '/usr/lib/libicuio.73.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuio.73.dylib' (no such file), '/usr/local/lib/libicuio.73.dylib' (no such file), '/usr/lib/libicuio.73.dylib' (no such file, not in dyld cache) Warning: The post-install step did not complete successfully You can try again using:   brew postinstall php@8.1 | 
phpbrewを叩くと最初と違うエラーに変わっています。
| 1 2 | $ phpbrew __phpbrew_php_exec:15: /opt/homebrew/bin/phpbrew: bad interpreter: /opt/homebrew/opt/php@8.1/bin/php: no such file or directory | 
linkすると、
| 1 | $ brew link php@8.1 | 
また最初のエラーに戻るだけです。
ちなみに、
| 1 | $ brew reinstall php@8.1 | 
にしても同じでした。
ここで勘付きましたが、再インストールしても、参照しているパスが変わらないということは、ソースからコンパイルされていないということかな、という気がしました。なので、きちんとコンパイルされる方法でインストールしてみることにしました。
| 1 | $ brew reinstall --build-from-source php@8.1 | 
以下の英語の記事を参考にしました。
How can I force homebrew to recompile?
すると、先ほどのWarningも出ずにきちんとインストールできたようです。PHPbrewも無事動きました。
先ほどのlibxml2はこのようなオプションを指定しなくても、コンパイルからしてくれたみたいなのですが、PHPの場合はそうはいかないみたいですね。これもそれぞれのFormulaで設定されているのかもしれません。
MySQLがおかしい
上述したPHPbrewがおかしくなった一件から3か月位経ち、完全にこの件について忘れた頃でした。あるきっかけでMacを再起動したんですよね。
その後、ローカルのWordPressにブラウザからアクセスしてみたら、どうもMySQLが起動していないようでした。
| 1 2 | $ brew services start mysql ==> Successfully started `mysql` (label: homebrew.mxcl.mysql) | 
普通にHombrewで起動したら成功したように見えますが、
| 1 2 3 4 5 | $ brew services list Name    Status  User  File httpd   stopped root  ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist mysql   stopped araky ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist php@8.1 none | 
MySQLは起動していません。(Apacheも起動していないのですが、それはまた別の理由でしたのでここでは無視します)
| 1 2 3 4 5 | $ brew services info mysql mysql (homebrew.mxcl.mysql) Running: ✘ Loaded: ✔ Schedulable: ✘ | 
Homebrewの起動方法だと情報が少ないので、以下のように直接起動してみたところ、色々情報が出ました。
| 1 2 3 4 | $ mysql.server start Starting MySQL ./opt/homebrew/Cellar/mysql/8.0.33_3/bin/mysqld_safe: line 199: 41546 Abort trap: 6           env MYSQLD_PARENT_PID=41435 nohup /opt/homebrew/Cellar/mysql/8.0.33_3/bin/mysqld --basedir=/opt/homebrew/Cellar/mysql/8.0.33_3 --datadir=/opt/homebrew/var/mysql --plugin-dir=/opt/homebrew/Cellar/mysql/8.0.33_3/lib/plugin --log-error=xxxxxnoMacBook-Air.local.err --pid-file=/opt/homebrew/var/mysql/xxxxxnoMacBook-Air.local.pid < /dev/null >> /opt/homebrew/var/mysql/xxxxxnoMacBook-Air.local.err 2>&1  ERROR! The server quit without updating PID file (/opt/homebrew/var/mysql/xxxxxnoMacBook-Air.local.pid). | 
以下にログが吐かれていることがわかったので、見てみました。
/opt/homebrew/var/mysql/xxxxxnoMacBook-Air.local.err
すると、
| 1 2 3 4 | 2023-10-04T09:06:24.6NZ mysqld_safe Starting mysqld daemon with databases from /opt/homebrew/var/mysql dyld[1327]: Library not loaded: /opt/homebrew/opt/icu4c/lib/libicuuc.73.dylib   Referenced from: <22C3716E-F831-354D-98D2-F9FBFD6F8DCB> /opt/homebrew/Cellar/mysql/8.0.33_3/bin/mysqld   Reason: tried: '/opt/homebrew/opt/icu4c/lib/libicuuc.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/icu4c/lib/libicuuc.73.dylib' (no such file), '/opt/homebrew/opt/icu4c/lib/libicuuc.73.dylib' (no such file), '/usr/local/lib/libicuuc.73.dylib' (no such file), '/usr/lib/libicuuc.73.dylib' (no such file, not in dyld cache), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuuc.73.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/Cellar/icu4c/72.1/lib/libicuuc.73.dylib' (no such file), '/opt/homebrew/Cellar/icu4c/72.1/lib/libicuuc.73.dylib' (no such file), '/usr/local/lib/libicuuc.73.dylib' (no such file), '/usr/lib/libicuuc.73.dylib' (no such file, not in dyld cache) | 
あっ、これはここまで読んだ方なら見覚えがあるやつですね。
| 1 2 3 4 5 6 7 | % ls /opt/homebrew/opt/icu4c/lib/ icu			libicui18n.72.1.dylib	libicuio.72.dylib	libicutest.a		libicutu.dylib		pkgconfig libicudata.72.1.dylib	libicui18n.72.dylib	libicuio.a		libicutest.dylib	libicuuc.72.1.dylib libicudata.72.dylib	libicui18n.a		libicuio.dylib		libicutu.72.1.dylib	libicuuc.72.dylib libicudata.a		libicui18n.dylib	libicutest.72.1.dylib	libicutu.72.dylib	libicuuc.a libicudata.dylib	libicuio.72.1.dylib	libicutest.72.dylib	libicutu.a		libicuuc.dylib | 
やはり、mysqlから参照しているファイル名に入っているバージョン番号が違うんですよね。
でも、なんで3か月も問題が起きなかったのでしょうか?
おそらく、前述したJavaインストール時にMySQLもアップデートされたのでしょうが、PHPと違って、MySQLはバックグラウンドで動作していたのでずっとアップデート前の状態でメモリー上に入っていたと思われます。なので、再起動するまで問題が起きなかったのでしょう。Apacheもバックグラウンドで動作していますが、設定ファイルを変更をして反映させるための再起動をする機会が多かったため、比較的すぐに気が付くことができました。MySQLの場合は、一度も設定ファイルを変更する機会がありませんでした。
なので、MySQLも再インストールします。
| 1 | $ brew uninstall mysql | 
してから、
| 1 | $ brew install mysql | 
でインストールはできましたが、
| 1 2 | $ brew services start mysql Error: Formula `mysql` has not implemented #plist, #service or installed a locatable service file | 
なぜかエラーが出ました。リンクがおかしいのかな、と思って
| 1 2 | $ brew link mysql Linking /opt/homebrew/Cellar/mysql/8.0.33_2.reinstall... 99 symlinks created. | 
するとコマンド自体は成功しますが、
| 1 2 | $ brew services start mysql ==> Successfully started `mysql` (label: homebrew.mxcl.mysql) | 
なぜか起動していません。
| 1 2 3 4 5 | $ brew services info mysql mysql (homebrew.mxcl.mysql) Running: ✘ Loaded: ✔ Schedulable: ✘ | 
やはり、またソースコードからコンパイルしなければいけないのかなと思って、
| 1 |  $ brew reinstall --build-from-source mysql | 
とします。
| 1 2 | Warning: building from source is not supported! You're on your own. Failures are expected so don't create any issues, please! | 
と怖いことを言われますが、無視します。
割と時間がかかって終わるのか心配でしたが、終わりました。
それでも、まだ起動できませんでした。また先ほどのログを見ると
| 1 2 3 | 2023-10-10T10:10:31.167397Z 0 [ERROR] [MY-010270] [Server] Can't start server : Bind on unix socket: Address already in use 2023-10-10T10:10:31.167405Z 0 [ERROR] [MY-010258] [Server] Do you already have another mysqld server running on socket: /tmp/mysql.sock ? 2023-10-10T10:10:31.167416Z 0 [ERROR] [MY-010119] [Server] Aborting | 
と、気になるエラーが出ていました。ネットで調べてみると、以下を見つけました。
MySQLがERROR! The server quit without updating PID fileで起動できないときにやったこと
| 1 2 | $ rm /tmp/mysql.sock override rw-r--r-- root/wheel for /tmp/mysql.sock? | 
overrideという見慣れぬワードが表示されます。消したはずなのに、すぐにまたこのファイルが生成されます。
でも、これでなぜかMySQLが動き出していました。
| 1 2 3 4 5 | $ brew services info mysql mysql (homebrew.mxcl.mysql) Running: ✔ Loaded: ✔ Schedulable: ✘ | 
さいごに
Macの根幹を支えるパッケージマネージャーであるHomebrewは、結構アグレッシブな仕様だったりします。この辺りしっかり理解することと、適切な対処をすることが大事ですが、それでもなおHomebrewを使う理由はあります。それを以下で説明していますので、ご覧ください。

 
											 
						
						
						
												 
						
						
						
												