Error Permission denied when running brew cleanup

在Mac运行 “brew cleanup ” 命令时,提示以下错误:

==> `brew cleanup` has not been run in 30 days, running now...
Pruned 0 symbolic links and 9 directories from /usr/local
Error: Permission denied @ apply2files - /usr/local/lib/node_modules/cordova/node_modules/extglob/lib/.DS_Store

提示没有权限,于是加上sudo: 还是报错:

Error: Running Homebrew as root is extremely dangerous and no longer supported.
As Homebrew does not drop privileges on installation you would be giving all
build scripts full access to your system.

最终找到解决办法,运行以下命令,在运行cleanup:

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

你可能感兴趣的:(Mac)