LoginSignup
13
7

More than 5 years have passed since last update.

brew cleanupでDirectory not emptyとなった場合の対処

Posted at

経緯

brew cleanupを実行した際にerrorで終了しました。

$ brew cleanup
Removing: /usr/local/Cellar/icu4c/62.1... (250 files, 67.3MB)
Error: Directory not empty @ dir_s_rmdir - /usr/local/Cellar/icu4c/62.1

解決に意外と手こずった上、原因は単純なものだったので対処法を残しておきます。

確認

エラーとなったディレクトリの情報を確認します。

ls -l /usr/local/Cellar/icu4c/
total 0
drwxr-xr-x  12 test  admin  384 Aug 20 15:52 62.1
drwxr-xr-x  12 user  staff  384 Dec 18 17:29 63.1

以前お試し用に作ったユーザーでinstallを実行した際にファイルが作成されたため、権限がなくてエラーになっていたようです。

対処

ユーザーとグループを修正します。(ユーザーだけでもいいかも)

$ sudo chown -R user:staff /usr/local/Cellar/icu4c/

正しいものに変更されていることを確認します。

$ ls -l /usr/local/Cellar/icu4c
total 0
drwxr-xr-x  12 user  staff  384 Aug 20 15:52 62.1
drwxr-xr-x  12 user  staff  384 Dec 18 17:29 63.1

再実行

$ brew cleanup
:
:
==> This operation has freed approximately 1.6GB of disk space.
$ ls -l /usr/local/Cellar/icu4c
total 0
drwxr-xr-x  12 user  staff  384 Dec 18 17:29 63.1

cleanupが正常終了し、ディレクトリも削除されました。

おそらくディレクトリを直接削除するだけでいいとは思いますが、brewが他に何かしているかもしれないので権限を修正してbrewに削除させるのが安全でしょう。

13
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
7