bun icon indicating copy to clipboard operation
bun copied to clipboard

ZSH "Insecure Directories" Error After Running Install Script on MacOS

Open NateLevin1 opened this issue 3 years ago • 16 comments
trafficstars

From this discord message.

After downloading Bun via the install script on macOS, upon opening a new terminal, the following message is output:

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

The simple fix is to comment out the line after # bun completions in ~/.zshrc, but I think fixing this would make downloading bun "just work" better out of the box. I'll look into this further to see if I can figure out the root cause of the issue.

Edit: The problem is specifically to do with the source "/Users/NAME/.bun/_bun" command which is added to the zshrc on install. When executed, it prints the error message above.

NateLevin1 avatar Jul 06 '22 02:07 NateLevin1

The issue happens because /usr/local/share/zsh is an "insecure directory" (according to compaudit.)

To fix the issue you need to run:

sudo chmod g-w /usr/local/share/zsh/site-functions
sudo chmod g-w /usr/local/share/zsh

Since this requires sudo I assume this isn't something you want to have added to the install script.

Might be worth adding this info to the Troubleshooting section of the README, I can PR it if necessary.

NateLevin1 avatar Jul 06 '22 02:07 NateLevin1

Waiting for the Bun development team can resolve this problem radically.

wukaipeng-dev avatar Jul 23 '22 14:07 wukaipeng-dev

I am try to use this solution but didn't work. @UltimatePro-Grammer

image

wukaipeng-dev avatar Jul 30 '22 06:07 wukaipeng-dev

@Penggeor Show me the compaudit after running those commands - if you still can’t figure it out you can always get rid of the lines after # bun completions in the .zshrc

The post and its comments on this stack overflow answer may help.

NateLevin1 avatar Jul 30 '22 15:07 NateLevin1

Hi @UltimatePro-Grammer, thanks for filing this issue and sorry about the install trouble. Is this still happening when you install using the curl script?

Electroid avatar Nov 01 '22 21:11 Electroid

@Electroid Yes, I am still able to reproduce this issue. Also, the code causing the problem has not been modified. It seems to be a problem fundamental to ZSH experienced by lots of projects, so a troubleshooting note might be best.

NateLevin1 avatar Nov 13 '22 03:11 NateLevin1

I've used the above method, but the installation still reports an error

king-open avatar Jan 14 '23 11:01 king-open

@king-open What is the output of compaudit after you have run the solution above? It would also be useful if you could provide the output of ls -lh /usr/local/share/zsh

NateLevin1 avatar Jan 15 '23 03:01 NateLevin1

@NateLevin1 i ran that command for all of these directories and the error still occurs. here's the output of compaudit. it doesn't seem to remove them from this list:

% compaudit
There are insecure directories and files:
/usr/local/share/zsh/site-functions
/usr/local/share/zsh
/usr/local/share/zsh/site-functions/_brew
/usr/local/share/zsh/site-functions/_brew_services
/usr/local/share/zsh/site-functions/_carthage
/usr/local/share/zsh/site-functions/_git

It would also be useful if you could provide the output of ls -lh /usr/local/share/zsh

total 0
drwxr-xr-x  7 not-me  admin   224B Sep  8 11:38 site-functions

neither the not-me or admin accounts are my user, so maybe that's the issue?

DetachHead avatar Sep 13 '23 04:09 DetachHead

@DetachHead You might have some luck trying one of the solutions from this thread: https://github.com/zsh-users/zsh-completions/issues/680#issuecomment-612960481 . It could be that the user differs as well.

NateLevin1 avatar Sep 13 '23 12:09 NateLevin1

I'm getting this message when installing bun from a different user on my mac. A few of the suggestions here didn't work for me. I decided to comment out source "/Users/nickmanning/.bun/_bun" in ~/.zshrc.

nickmanning214 avatar Oct 15 '23 09:10 nickmanning214

Installing Bun from NPM worked for me

pnpm -g i bun

present-g avatar Jan 23 '24 11:01 present-g