完美解决Error: Running Homebrew as root is extremely dangerous and no longer supported.

在macOS High Sierra(10.13.6)及以上版本的Mac上面,使用brew install安装时老是报错,因为苹果已经不允许Homebrew作为根来安装了。
详细提示:

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.

所以在新版本的Mac电脑上面使用brew命令安装老是报错。
比如:
你使用brew install kompose安装时提示:权限不足

Error: Permission denied @ apply2files - /usr/local/lib/node_modules/hexo/node_modules/[email protected]@micromatch/lib/.DS_Store

当你添加sudo brew install kompose安装时提示:危险操作。

网上很多做法是把/usr/local路径改成当前用户路径,但是在高版本的Mac上面已经不允许了:

sudo chown -R $(whoami) /usr/local
chown: /usr/local: Operation not permitted

解决方案

执行下面的命令:

$ sudo chown -R `whoami` /usr/local/Homebrew/
$ sudo chown -R $(whoami) $(brew --prefix)/*
$ sudo mkdir /usr/local/Frameworks
$ sudo chown -R `whoami` /usr/local/Frameworks/

之后,再执行brew install kompose就可以安装啦!!!
完美解决Error: Running Homebrew as root is extremely dangerous and no longer supported._第1张图片

你可能感兴趣的:(技术博客)