Mac OS X 下不能 brew update 的问题

我在 Mac OS X 下执行 brew update 出错

➜   brew update
error: Your local changes to the following files would be overwritten by merge:
    Library/Formula/abcde.rb
    Library/Formula/acpica.rb
    ............
    Library/Formula/pypy.rb
    Library/For
error: The following untracked working tree files would be overwritten by merge:
    Library/Aliases/actor-framework
    Library/Formula/aescrypt-packetizer.rb
    ............
    Library/Formula/stlink.rb
    Library/Formula/with-readline.rb
Please move or remove them before you can merge.
Aborting
Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master

找到一个解决办法

cd brew --prefix     #fish 下用 cd (brew --prefix),一般就是 /usr/local 目录
git remote add origin https://github.com/mxcl/homebrew.git     #可能已经有这个了
git fetch origin
git reset --hard origin/master   #这个才是关键
git clean -df

然后再执行 brew update, 可能会说

Even if this directory was writable when you installed Homebrew, other
software may change permissions on this directory. Some versions of the
"InstantOn" component of Airfoil are known to do this.

You should probably change the ownership and permissions of /usr/local
back to your user account.
  sudo chown -R $(whoami):admin /usr/local

那就改目录权限吧,fish 下用 sudo chown -R (whoami):admin /usr/local。或者 sudo brew update,改目录权限以后会省事些。

再做 brew update 成功,运行下 brew upgrade 发现好多软件要更新。

参考:1. Cannot "brew update" anymore - fails to git pull formulas #11448

 


后来一次碰到执行 brew install docker  也就是 brew update 报了也是关于 ruby 的错误

/ 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>'

解决办法是一样一样的。

本文链接 https://yanbin.blog/mac-os-x-issue-of-brew-update/, 来自 隔叶黄莺 Yanbin Blog

[版权声明] Creative Commons License 本文采用 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0) 进行许可。

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments