macOS使用Homebrew安装软件

前言

Homebrew官网


报错问题

直接使用brew命令可能会遇到报错,例如

1
2
3
4
brew install wget
==> <省略...>
==> <省略...>
Error: Permission denied

而使用sudo brew同样会遇到报错,例如

1
2
3
4
5
sudo brew install wget
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.

从网上找到一种做法

1
2
3
sudo chown -R $(whoami) /usr/local
Password:
chown: /usr/local: Operation not permitted

解决方案

chown: /usr/local: Operation not permitted问题解决这里找到了解决方案

/usr/local 不再被 chown’d in High Sierra

1
sudo chown -R $(whoami) $(brew --prefix)/*

问题解决。


后记

如何获取旧版 macOS