zsh compinit: insecure directories, run compaudit for list

21,280

Solution 1

You can list those insecure folders by:

compaudit

The root cause of "insecure" is these folders are group writable.

There's a one line solution to fix that:

compaudit | xargs chmod g-w

Please see zsh, Cygwin and Insecure Directories and zsh compinit: insecure directories for reference.

Solution 2

I encountered the same problem after following https://docs.npmjs.com/getting-started/fixing-npm-permissions, and I solved it using:

% cd /usr/local/share/zsh
% sudo chmod -R 755 ./site-functions
% sudo chown -R root:root ./site-functions

I found the answer here: https://stackoverflow.com/questions/13762280/zsh-compinit-insecure-directories

Solution 3

I'm using WSL and the above solutions didn't fix it for me, but they did lead me towards this incantation which did fix it:

cd ~
compaudit | xargs chown -R "$(whoami)"
compaudit | xargs chmod -R go-w

Solution 4

This morning, some packages in my system updated, and left me with this error message.

Apparently, something in the update changed the username and group to numbers, instead of root, as so:

# There are insecure files: /usr/share/zsh/vendor-completions/_code
# sudo ls -alh
-rw-r--r-- 1  131  142 2.6K 2019-10-10 16:28 _code

I simply changed the user and group for this file back to root and the problem went away. I did not need to change any permissions, and would caution against doing so unless the underlying cause of the problem is understood.

sudo chown root _code && sudo chgrp root _code

After switching 131 and 142 back to root, this error message from zsh went away.

Solution 5

When I would run compaudit, I would get the insecure directories error from the plugins directory of oh-my-zsh. So I changed the permissions in the plugins directory:

  • cd /home/${usr}/.oh-my-zsh/custom/
  • sudo chmod -R 755 ./plugins

fixed the issue for me.

Ubuntu 16.0.4 on WSL.

Share:
21,280
Luv33preet
Author by

Luv33preet

Updated on September 18, 2022

Comments

  • Luv33preet
    Luv33preet over 1 year

    When I try to login as root, this warning comes up.

    luvpreet@DHARI-Inspiron-3542:/$ sudo su
    Password: 
    zsh compinit: insecure directories, run compaudit for list.
    Ignore insecure directories and continue [y] or abort compinit [n]? 
    

    If I say yes, it simply logs in, and my shell changes from bash to zsh.

    If I say no, it says that ncompinit: initialization aborted and logs in.

    After login, my shell changes to zsh.

    All I ever did related to zsh, was download oh-my-zsh from github.

    What is happening and why ?

    Using - Ubuntu 16.04 on Dell.

  • SOosterwaal
    SOosterwaal about 6 years
    This one-liner fixed my problem 👍
  • Ezra
    Ezra about 5 years
    My insecure directory was also other-writable, so I had to use "chmod o-w" in addition.
  • Shahbaz Shueb
    Shahbaz Shueb over 4 years
    This worked for me too.
  • Md. Abu Taher
    Md. Abu Taher over 4 years
    I had to cd into /usr/share/zsh/vendor-completions and this worked. :)
  • JdeBP
    JdeBP about 4 years
    One should also be investigating the underlying cause of why installing stuff is giving away root's ownership of global scripts.
  • zfogg
    zfogg over 2 years
    this works for WSL2 Arch just fine :) thanks