0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

zsh compinit: insecure directoriesが、かなりうざい

Posted at

なんか気づけばターミナル起動時に、こんな警告がいつもでる。

ターミナルの起動時にいつも、、、警告。

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

検索したら、AIが勝手にこんなん言うてくる。こわっ。。。

Zshの補完機能(compinit)が、書き込み権限が適切でない
(他のユーザーが改ざんできる状態の)ディレクトリやファイルを読み込もうとしている、
というセキュリティ上の問題を示しています

本気で警告つぶそう!

一瞬、え!?ってなったけど、まあ、問題ないけど(ユーザー自分だけやし)

  • 起動時に、毎回かなりうざい
  • Yes Or NoでNoって言ってるのに何回も繰り返される
  • 軽く調べながら、ちょいちょいやっても効果なし
  • これは困っている人も少しはいるだろうなと

原因・対策

compinit (zshの補完システム) が安全でないパーミッションのディレクトリを検出している。
補完ファイルのディレクトリが、他のユーザーに書き込み権限があると判断されている。

権限問題?
なんで?コマンドを実行してみる

$ compaudit
     /opt/homebrew/share/zsh/site-functions
     /opt/homebrew/share/zsh
     /opt/homebrew/share/zsh/site-functions/_aws
     /opt/homebrew/share/zsh/site-functions/_brew
     /opt/homebrew/share/zsh/site-functions/_gh
     /opt/homebrew/share/zsh/site-functions/_p11-kit
     /opt/homebrew/share/zsh/site-functions/_parallel

Homebrewまわりだね。
じゃあ、権限変えたらどうなる?

$ chmod go-w /opt/homebrew/share/zsh /opt/homebrew/share/zsh/site-functions
$ compaudit
     /opt/homebrew/share/zsh/site-functions
     /opt/homebrew/share/zsh
     /opt/homebrew/share/zsh/site-functions/_aws
     /opt/homebrew/share/zsh/site-functions/_brew
     /opt/homebrew/share/zsh/site-functions/_gh
     /opt/homebrew/share/zsh/site-functions/_p11-kit
     /opt/homebrew/share/zsh/site-functions/_parallel

だめじゃん。。
ファイル含めて全部でどう?

compaudit | xargs chmod go-w
$ compaudit
     /opt/homebrew/share/zsh/site-functions
     /opt/homebrew/share/zsh
     /opt/homebrew/share/zsh/site-functions/_aws
     /opt/homebrew/share/zsh/site-functions/_brew
     /opt/homebrew/share/zsh/site-functions/_gh
     /opt/homebrew/share/zsh/site-functions/_p11-kit
     /opt/homebrew/share/zsh/site-functions/_parallel

効かないね(ま、前もこんなのが続いて、保留にしたから予想どおり)

なので、蓋します。

解決方法は2つ:

  1. 所有者を変更する (推奨):
    sudo chown -R $(whoami) /opt/homebrew/share/zsh

  2. または .zshrc で警告を完全に無視する:
    .zshrc の compinit -i の前に以下を追加:
    ZSH_DISABLE_COMPFIX=true

今回は、2でいきます

.zshrc開いて、追記してみた

$ vim ~/.zshrc
-----以下、vimで開いた内容---------
        省略
       33    
       34    
       35 +  ZSH_DISABLE_COMPFIX=true
       36    autoload -Uz compinit
       37  

どうかな?

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

そうか。じゃあ、一番上に変更!

$ vim ~/.zshrc
-----以下、vimで開いた内容---------    
        1 +  ZSH_DISABLE_COMPFIX=true
        2    autoload -Uz compinit
        3 

治りました!!! ♫ 
なんか時間がもったいない感じがすさまじい。。。。。

Last login: Fri Dec 12 10:33:49 on ttys014

[user2@mac:~/Dev]$ 

こんなくだらないことで、皆様も時間を失わないよう、と思い初投稿しました。
以上です。

0
0
2

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?