不能在MAC OS X el capitan中更新brew,并且通过`require`不断更新Load错误

我不知道为什么会发生这种情况,但我无法更新MAC OS X El Capitan中的brew。 我做了:

brew update

并得到:

 warning: unable to unlink CONTRIBUTING.md: Permission denied warning: unable to unlink SUPPORTERS.md: Permission denied fatal: cannot create directory at '.github': Permission denied 

为了解决这个问题,我提到了上面的命令,但是得到了更多的问题:

 sudo brew update Password: /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/brew.rb:16:in `<main>' 

现在每当我做brew安装,我得到:

 brew update /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /usr/local/Library/brew.rb:16:in `<main>' 

事实上,似乎每当我做任何事情,就像inputbrew ,就会得到相同的信息。 有谁知道如何解决这一问题?

你不应该用自制软件sudo 。 首先运行以下命令以确保您拥有/usr/local下的所有内容:

 sudo chown -R $(whoami):admin /usr/local 

然后重置你的自制软件仓库到一个干净的状态:

 cd /usr/local && git fetch && git reset --hard origin/master 

它应该解决你的问题。

(如果你在其他地方安装了Homebrew,用/usr/local $(brew --prefix)replace/usr/local