问题描述
我不确定为什么会这样,但是我无法在我的MAC OS X El Capitan中更新brew.我做到了:
I am not sure why this is happening but I cannot update brew in my MAC OS X El Capitan. I did:
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
要解决该问题,我对上面的命令进行了处理,但又遇到了更多问题:
to go over that issue I sudoed the above command but got further issues:
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安装时,我都会得到:
now whenever I do brew install I get:
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>'
实际上,似乎只要执行任何操作(例如键入brew
),它都会收到相同的消息.有人知道如何解决这个问题吗?
in fact, it seems that whenever I do anything, like just type brew
it gets the same message. Does anyone know how to fix this?
推荐答案
您不应将sudo
与Homebrew一起使用.首先运行以下命令以确保您拥有/usr/local
下的所有内容:
You shouldn’t use sudo
with Homebrew. First run the following to ensure you own everything under /usr/local
:
sudo chown -R $(whoami):admin /usr/local
更新的macOS版本的替代命令:
Alternative command for newer macOS version:
sudo chown -R $(whoami) $(brew --prefix)/*
然后将您的Homebr存储库重置为干净状态:
Then reset your Homebrew repo to a clean state:
cd /usr/local && git fetch && git reset --hard origin/master
它应该解决您的问题.
(如果在其他位置安装了Homebrew,请用$(brew --prefix)
替换/usr/local
)
(replace /usr/local
with $(brew --prefix)
if you installed Homebrew elsewhere)
这篇关于无法在MAC OS X el capitan中更新brew,并通过`require`不断收到Load错误.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!