MacOS Catalina で brew services start postgresql でエラー発生

新しいMacの設定中にエラーが発生したので、解決方法を記しておく。

エラー内容

% brew services start postgresql
Error: Permission denied @ rb_sysopen - /Users/hoge/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

結論
所有権の変更したらサービス開始できた!

対処方法

~/Library/LaunchAgentsのアクセス権限がなくてエラーになっているらしい。

root権限になっている
% ls -l ~/Library/
drwxrwxrwx    3 root  staff    96  3 18 23:10 LaunchAgents
hogeユーザーで利用可能にする
% sudo chown hoge ~/Library/LaunchAgents
drwxrwxrwx    3 hoge  staff    96  3 18 23:10 LaunchAgents
postgresqlのサービス開始できた!
% brew services start postgresql
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
フォルダへのアクセス権もおかしいなら下記コマンドで修正する
% chmod 755 ~/Library/LaunchAgents

参考

Fixing Homebrew Postgres Installation on macOS Catalina