Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
NateLevin1 opened this issue Jul 6, 2022 · 15 comments
Open
Labels
bug Something isn't working

Comments

@NateLevin1
Copy link

NateLevin1 commented Jul 6, 2022

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
Copy link
Author

NateLevin1 commented Jul 6, 2022

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 NateLevin1 changed the title ZSH Insecure Directories Error After Install ZSH "Insecure Directories" Error After Running Install Script on MacOS Jul 6, 2022
@Penggeor
Copy link

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

@Penggeor
Copy link

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

image

@NateLevin1
Copy link
Author

NateLevin1 commented Jul 30, 2022

@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.

@Electroid
Copy link
Contributor

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?

@github-actions github-actions bot removed the install label Nov 2, 2022
@NateLevin1
Copy link
Author

@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.

@king-open
Copy link

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

@NateLevin1
Copy link
Author

@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

@DetachHead
Copy link

DetachHead commented Sep 13, 2023

@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?

@NateLevin1
Copy link
Author

@DetachHead You might have some luck trying one of the solutions from this thread: zsh-users/zsh-completions#680 (comment) . It could be that the user differs as well.

@nickmanning214
Copy link

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.

@Electroid Electroid added the bug Something isn't working label Oct 24, 2023
@present-g
Copy link

Installing Bun from NPM worked for me

pnpm -g i bun

@emsspree
Copy link

Additionally, I had to change share itself:

sudo chmod go-w /usr/local/share

@wylu1037
Copy link

wylu1037 commented Oct 30, 2024

Environment

  • 💻: Mac

First step

Run the compaudit command to list insecure directories, examples are as follows:

There are insecure directories:
/opt/homebrew/share/zsh/site-functions
/opt/homebrew/share/zsh

Second step

Change the directory permissions.

chmod 755 /opt/homebrew/share/zsh/site-functions
chmod 755 /opt/homebrew/share/zsh

Third step

Now you can run the compaudit command once again.

🎉 It works for me.

@TTibbs
Copy link

TTibbs commented Nov 17, 2024

I have tried many suggestions, including the most recent made by @wylu1037 but it still persists:

There are insecure files:
/usr/local/share/zsh/site-functions/_brew_services
/usr/local/share/zsh/site-functions/_git
/usr/local/share/zsh/site-functions/_ninja
➜  ~ ls -ld /usr/local/share/zsh/site-functions           
drwxr-xr-x  7 tward  staff  224 14 Nov 13:26 /usr/local/share/zsh/site-functions
➜  ~ ls -l /usr/local/share/zsh/site-functions            
total 0
lrwxr-xr-x  1 tward  staff  39  9 Mar  2024 _brew -> ../../../Homebrew/completions/zsh/_brew
lrwxr-xr-x  1 tward  staff  88  2 Oct 10:12 _brew_services -> ../../../Homebrew/Library/Taps/homebrew/homebrew-services/completions/zsh/_brew_services
lrwxr-xr-x  1 tward  staff  56  9 Mar  2024 _git -> ../../../Cellar/git/2.44.0/share/zsh/site-functions/_git
lrwxr-xr-x  1 tward  staff  60 14 Nov 13:26 _ninja -> ../../../Cellar/ninja/1.12.1/share/zsh/site-functions/_ninja
lrwxr-xr-x  1 tward  staff  71  9 Mar  2024 git-completion.bash -> ../../../Cellar/git/2.44.0/share/zsh/site-functions/git-completion.bash

It started yesterday after I migrated everything from my old MacBook to my new one and it put my old user on there too, I have since deleted the old user from my new MacBook. I also have no idea who "staff" is. Any tips please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

10 participants