FAQ- Homebrew update error not work on OSX

brew update 错误是这样的

chown: /usr/local: Operation not permitted

然后网上osx 10.11, 10.12的解决方法这样的

The problem mainly occurs after updating OS X to El Capitan (OS X 10.11) or macOS Sierra (macOS 10.12). This is mainly because of file permission issues with El Capitan’s or later macOS's new SIP process. Try changing permissions of /usr/local directory.
$ sudo chown -R $(whoami):admin /usr/local 
If it still doesn't work, use following steps and everything will be fine. This may be because homebrew is not updated.
1. open terminal 
2. $ cd /usr/local/Library/Homebrew 
3. $ git reset --hard 
4. $ git clean -df
5. $ brew update

10.13之后库克怒了,不管你怎么执行命令都不让你运行 哪怕是root ,所以有人这么干:

看来只有关掉SIP了

1.重启Mac,按住Command + R键直到Apple Logo出现,进入Recovery Mode模式(我感觉我是按了好半天)

2.点击工具里的Terminal(终端)

3.输入csrutil disable,之后回车

4.重启Mac

5.重启完成后,终端中输入 sudo chflags norestricted /usr/local && sudo chown -R $(whoami):admin /usr/local

成功执行,没有报操作不允许了

(如果想重新开启安全设置,则重复1、2步骤,输入csrutil enable就可以了)

然而根本没这么麻烦 这样就可以搞定 OS X 10.13 brew not work (简单的说就是卸载了再安装)

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