経緯
brew install
や brew upgrade
などをした際に、以下のエラーが表示されてしまった
エラー内容
Error: Permission denied @ apply2files - /usr/local/lib/docker/cli-plugins
うまくいった対応
$ sudo chown -R $(whoami) $(brew --prefix)/*
コマンドの意味
brewコマンドでのインストール先のファイル・ディレクトリの所有者を現在のユーザーに変更します
細かく調査
実際にコマンドを打ってみたらすぐわかりました
-
brew --prefix
- brewコマンドでのインストール先のルートディレクトリを表示
-
$(brew --prefix)/*
- brewコマンドでのインストール先のファイルたちを指定
-
whoami
- 現在のユーザー名を表示
-
chown -R
-
man chown
をすると書いてありましたThe chown utility changes the user ID and/or the group ID of the specified files. Symbolic links named by arguments are silently left unchanged unless -h is used.
-
-R
についてはChange the user ID and/or the group ID for the file hierarchies rooted in the files instead of just the files themselves.
- 要するに指定したファイル以下のファイルのユーザーIDやグループIDを再帰的に変更
-
ちなみに
sudo brew
はもうダメみたいでした
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.