• 首页
  • 开发工具
  • brew update error: Your local changes to the following files would be overwritten by merge

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

brew_update_error.jpg

今天更新mac os 10.11.1 ,然后顺便更新了 xcode

然后我用 brew 安装 watchman

➜  /Users/zhangzhi  >brew install watchman

然后报错


==> Downloading https://github.com/facebook/watchman/archive/v2.9.3.tar.gz Already downloaded: /Library/Caches/Homebrew/watchman-2.9.3.tar.gz ==> ./autogen.sh ==> ./configure --prefix=/usr/local/Cellar/watchman/2.9.3 --with-pcre checking for gcc… clang checking whether the C compiler works… no configure: error: in /private/tmp/watchman-Ww0t/watchman-2.9.3': configure: error: C compiler cannot create executables Seeconfig.log’ for more details Error: Homebrew doesn’t know what compiler versions ship with your version of Xcode (7.1). Please brew update and if that doesn’t help, file an issue with the output of brew --config: https://github.com/Homebrew/homebrew/issues

Note that we only track stable, released versions of Xcode.

Thanks!

READ THIS: https://github.com/Homebrew/homebrew/wiki/troubleshooting


于是打算升级 brew

➜  /Users/zhangzhi  >brew update

接着出现了这样的错误


error: Your local changes to the following files would be overwritten by merge: Library/ENV/4.3/xcrun Library/brew.rb Please, commit your changes or stash them before you can merge. Aborting Error: Failure while executing: git pull -q origin refs/heads/master:refs/remotes/origin/master ➜ /Users/zhangzhi >brew doctor Warning: The /usr/local directory is not writable. 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.

Warning: Ruby version 2.0.0 is unsupported. Homebrew is developed and tested on Ruby 1.8.x, and may not work correctly on other Rubies. Patches are accepted as long as they don’t break on 1.8.x. Error: Homebrew doesn’t know what compiler versions ship with your version of Xcode (7.1). Please brew update and if that doesn’t help, file an issue with the output of brew --config: https://github.com/Homebrew/homebrew/issues

Note that we only track stable, released versions of Xcode.

Thanks!


无法获取最新的代码,于是我开启 brew 诊断模式看看

➜  /Users/zhangzhi  >brew doctor

诊断信息如下:


Warning: The /usr/local directory is not writable. 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.

Warning: Ruby version 2.0.0 is unsupported. Homebrew is developed and tested on Ruby 1.8.x, and may not work correctly on other Rubies. Patches are accepted as long as they don’t break on 1.8.x. Error: Homebrew doesn’t know what compiler versions ship with your version of Xcode (7.1). Please brew update and if that doesn’t help, file an issue with the output of brew --config: https://github.com/Homebrew/homebrew/issues

Note that we only track stable, released versions of Xcode.

Thanks!


第一个问题: The /usr/local directory is not writable.

/usr/local 目录竟然没有写的权限

我们需要 sudo 权限下给 /usr/local 目录改变权限

sudo chown -R $USER /usr/local

运行后, /usr/local 已经有了读写权限

第二个问题,拉取最新的 brew 代码

按照从上到下步骤依次运行

    1. cd brew --prefix
    1. git remote add origin https://github.com/mxcl/homebrew.git
      
    1. git fetch origin
      
    1. git reset --hard origin/master
      

上面步骤依次执行完以后,再去更新 brew update

➜  /usr/local git:(master) >brew update

最后结果:


➜  /usr/local git:(master) >brew update
Already up-to-date.

提示你更新完成

出自:brew update error: Your local changes to the following files would be overwritten by merge



回到顶部