开发者

Error while trying to update brew package manager

I tried to update brew:

sudo brew updat开发者_运维百科e

But I got this error:

error: Your local changes to the following files would be overwritten by merge:

Listing a lot of files

Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master

Any idea what is going wrong?


There was a bug in Homebrew that was fixed just a few days ago. To fix the bug you can run git reset --hard FETCH_HEAD inside your Homebrew installation. Since that won't fix files that are already seen as modified you can also run git checkout Library to replace your checkout with the latest files. (That wipes all edits so take appropriate measures with any you made.)


The accepted answer is correct but incomplete. If you are getting the error of

error: The following untracked working tree files would be overwritten by merge:

Then go to your terminal and run these commands

cd /usr/local

Then

git reset --hard FETCH_HEAD

Then

git checkout Library

That should get everything in order. Then run

brew update


Let me add: cd /usr/local/git and then run git reset --hard FETCH_HEAD


go to your terminal and run these commands

cd /usr/local

sudo git reset --hard FETCH_HEAD

sudo git checkout Library


For those of you using OS X El Capitan, your problem may be System Integrity Protection.

If /usr/local exists already, run the following in Terminal:

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

If /usr/local does not exist:

First, try to create /usr/local the normal way:

sudo mkdir /usr/local && sudo chflags norestricted /usr/local && sudo chown -R $(whoami):admin /usr/local

If you see permission issues instead try:

  1. Reboot into Recovery mode (Hold Cmd+R on boot) & access the Terminal.
  2. In that terminal run: csrutil disable
  3. Reboot back into OS X
  4. Open your Terminal application and execute the line from just above
  5. Reboot back into Recovery Mode & access the Terminal again.
  6. In that terminal execute: csrutil enable
  7. Reboot back into OS X & you'll be able to write to /usr/local & install Homebrew.


Out of no reason (or at least no one I'd understand) the repository in /usr/local (which is the brew install!) lost its remote repository. So, neither a git reset nor a git pull and for sure no brew update would work.

How do you know that happened? Check /usr/local/.git/config whether there are some lines like the following:

[remote "origin"]
url = http://github.com/mxcl/homebrew.git
fetch = +refs/heads/*:refs/remotes/origin/*

If not do as follows:

cd /usr/local
git remote add origin http://github.com/mxcl/homebrew.git
git pull origin master
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜