昨天用brew安装了些程序后,不知道哪根筋不对,顺手brew update。
今天使用的时候显示:
$ brew
/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- mach (LoadError)
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/Library/Homebrew/global.rb:3:in `'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /usr/local/Library/brew.rb:15:in `'
stack overflow上的解决办法: homebrew not working on OSX
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