🖥️

brew upgrade で Error: Permission denied @ apply2files が発生したときの対処方法

2023/01/21に公開

概要

Macにてhomebrewのアップグレードを行った際に以下のエラーが出たので対処法を書きました

Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

対処方法

brew upgrade の前に以下のコマンドを実行することで解消することができます

$ sudo chown -R $(whoami) $(brew --prefix)/*

対処法を実行した結果

$ brew upgrade
==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Pruned 1 symbolic links and 5 directories from /usr/local

となり、無事に upgrade することができました🎉

appendix

sudoで実行しても変わらずでした

$ sudo brew upgrade
Password:
Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.
$ brew upgrade
Running `brew update --auto-update`...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).

==> `brew cleanup` has not been run in the last 30 days, running now...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins

参考

Discussion