LoginSignup
0
2

More than 1 year has passed since last update.

zsh compinit: insecure directories and filesをファイルの権限を変えずに黙らせる

Posted at

Mac OS Ventura 13.1でアカウントが2つある状況で、1つ目のアカウントでhomebrewを使ってインストールしたzshを2つ目のアカウントで使うとワーニングが出た。

zsh compinit: insecure directories and files, run compaudit for list.
Ignore insecure directories and files and continue [y] or abort compinit [n]?

ググると compaudit を行い、これらのディレクトリの権限がよくないので適切な権限に変えればよいらしい。
chmodchown を使って権限を変更したら確かにエラーは出なくなったのだが、1つ目のアカウントでbrewでzshをアップデートできなくなってしまったので、仕方なく元に戻した。

そもそもなんで怒られるのだろう?

For security reasons compinit also checks if the completion system would use files not owned by root or by the current user, or files in directories that are world- or group-writable or that are not owned by root or by the current user.

なるほど。書き込み権限を適切にしても変わらずワーニングが出るので、ワーニングが出るディレクトリの所有者がrootでも今のユーザーでもないのがいけないっぽい。

To avoid these tests and make all files found be used without asking, use the option -u, and to make compinit silently ignore all insecure files and directories use the option -i. This security check is skipped entirely when the -C option is given.

どうも compinit にはいくつかオプションがあり、このワーニングを無視できるそう。自分のzshrcを見ると -u でcompinitを呼んであった。

autoload -Uz compinit && compinit -u

上記のドキュメント読んだ感じでは、 -u でも -i でも -C でもワーニング無視してくれそうに見えるが、全部試したところ、 -i のみワーニングを抑制してくれた。

-autoload -Uz compinit && compinit -u
+autoload -Uz compinit && compinit -i

なぜうまくいったのかはよくわからないけれど、ディレクトリの所有者が2つ目のアカウントのユーザーでないので怒られるのは問題ないと思うので、しばらくワーニングを無視で使ってみる。

参考

0
2
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
0
2