Kishore S
Kishore S

Reputation: 2191

macOS - Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib/.DS_Store?

I was installing the starship via homebrew, but I am getting this error:

Permission denied @ apply2files - /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib/.DS_Store

Any solution for fixing this error?

Thanks.

Upvotes: 209

Views: 145572

Answers (13)

Sion Gao
Sion Gao

Reputation: 41

For latest version of MacOS, I cannot use * to match subdirectories' patterns, zsh reports error:

➜  ~ sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*
chown: /usr/local/*: No such file or directory

So instead, you can simply use ls to find subdirectories and send to chown:

cd /usr/local
sudo chown -R $(whoami):admin `ls` \
&& sudo chmod -R g+rwx `ls`

Wait for a while and the operation shall succeed.

Upvotes: 1

Taysay
Taysay

Reputation: 19

In my case it worked with:

sudo chown -R $(whoami) /usr/local/lib/python3.11/*

Upvotes: 0

Francesco Onorati
Francesco Onorati

Reputation: 301

I had the same problem, and the solutions suggested didn't fix it. I had to change the ownership of homebrew folder and subfolders

sudo chown -R $(whoami) /opt/homebrew/*

Upvotes: 20

Touseef Murtaza
Touseef Murtaza

Reputation: 1956

for me, the issue was with the permission of homebrew while cleaning the old packages brew cleanup

sudo chown -R ${LOGNAME}:staff /opt/homebrew/lib/

Upvotes: 2

Manoj Daswani
Manoj Daswani

Reputation: 611

If you are getting the above error during brew cleanup “Permission denied @ apply2files”, one of the solutions which worked in my case was to reset permissions to /usr/local. You will have to rewrite permission to the current user. In your terminal copy and paste:

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

Then rerun the command. The permission error should go.

Hope it may help someone in the future. Good luck

Upvotes: 60

Jerry Chong
Jerry Chong

Reputation: 9240

This issue appeared after upgrading macOS to Mojave 10.14.X onwards.

Therefore, you need to reset the permissions in /usr/local:

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

Source: https://github.com/Homebrew/homebrew-core/issues/45009#issuecomment-543795948

Upvotes: 405

PrimeDime
PrimeDime

Reputation: 149

what worked for me, simply delete the directory with

sudo rm -rf %error file path%

Upvotes: -1

Douglas Mesquita
Douglas Mesquita

Reputation: 920

In my case, It works with

sudo chown -R douglas.mesquita:admin /usr/local/lib/node_modules

Upvotes: 0

Gupta
Gupta

Reputation: 10388

This work for me.

Remove and reinstall brew.

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

Upvotes: 0

Motoko
Motoko

Reputation: 31

first

sudo chown -R $(whoami):admin /usr/local/* \
&& sudo chmod -R g+rwx /usr/local/*

the reinstall all the packages with

brew list --formula | xargs brew reinstall

this part may take few minutes but worked great for me

Upvotes: 3

Philippe
Philippe

Reputation: 26727

You can change owner by :

sudo chown -R ${LOGNAME}:staff /usr/local/lib/node_modules

Upvotes: 143

Milind Patel
Milind Patel

Reputation: 2807

Change permission of the node_modules directory by running

sudo chown -R ${LOGNAME}:staff /usr/local/lib/node_modules

Upvotes: 2

Cui Yang
Cui Yang

Reputation: 51

You can run the command: sudo chmod 755 /usr/local/lib/node_modules/expo-cli/node_modules/extglob/lib/.DS_Store

Upvotes: 1

Related Questions