brew cleanup遇到Permission denied @ apply2files [Mac Homebrew]

brew cleanup遇到Permission denied @ apply2files [Mac Homebrew]

  • 参考: https://aoh.cc/archives/28/

1. 问题

执行命令:

brew cleanup

报错:

Warning: Skipping automake: most recent version 1.16.2 not installed
Warning: Skipping etcd: most recent version 3.4.8 not installed
Warning: Skipping gd: most recent version 2.3.0 not installed
Warning: Skipping git-lfs: most recent version 2.11.0 not installed
Warning: Skipping glib: most recent version 2.64.3 not installed
Warning: Skipping go: most recent version 1.14.3 not installed
Warning: Skipping libffi: most recent version 3.3 not installed
Warning: Skipping meson: most recent version 0.54.2 not installed
Warning: Skipping mysql-client: most recent version 8.0.19 not installed
Warning: Skipping pcre: most recent version 8.44 not installed
Warning: Skipping python: most recent version 3.7.7 not installed
Warning: Skipping sphinx-doc: most recent version 3.0.3 not installed
Warning: Skipping sysbench: most recent version 1.0.20 not installed
Warning: Skipping telnet: most recent version 63 not installed
Error: Permission denied @ apply2files - /usr/local/share/Library/Caches/Yarn/v6/npm-micromatch-3.1.10-70859bc95c9840952f359a068a3fc49f9ecfac23-integrity/node_modules/micromatch/lib/.DS_Store

2. 解决办法

显然是权限不够引起的问题,添加sudo权限,结果Homebrew不允许root权限下运行。

zzh@zzhdeMBP ~ % sudo brew cleanup
Password:
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.

只能求次进行解决,分配文件夹权限给当前用户。

sudo chown -R $(whoami) /usr/local/share

本想分配/usr/local文件夹的权限,结果不行。

运行结果如下。

zzh@zzhdeMBP ~ % sudo chown -R $(whoami) /usr/local
chown: /usr/local: Operation not permitted
zzh@zzhdeMBP ~ % sudo chown -R $(whoami) /usr/local/share
zzh@zzhdeMBP ~ % brew cleanup
Warning: Skipping automake: most recent version 1.16.2 not installed
Warning: Skipping etcd: most recent version 3.4.8 not installed
Warning: Skipping gd: most recent version 2.3.0 not installed
Warning: Skipping git-lfs: most recent version 2.11.0 not installed
Warning: Skipping glib: most recent version 2.64.3 not installed
Warning: Skipping go: most recent version 1.14.3 not installed
Warning: Skipping libffi: most recent version 3.3 not installed
Warning: Skipping meson: most recent version 0.54.2 not installed
Warning: Skipping mysql-client: most recent version 8.0.19 not installed
Warning: Skipping pcre: most recent version 8.44 not installed
Warning: Skipping python: most recent version 3.7.7 not installed
Warning: Skipping sphinx-doc: most recent version 3.0.3 not installed
Warning: Skipping sysbench: most recent version 1.0.20 not installed
Warning: Skipping telnet: most recent version 63 not installed
Pruned 0 symbolic links and 6 directories from /usr/local
zzh@zzhdeMBP ~ %

你可能感兴趣的:(问题集锦,Mac,工具使用,mac,brew)