Brew更新失败:未跟踪的工作树文件将被合并覆盖。

208

尝试使用 brew update 更新Homebrew时,我收到了以下错误信息。

error: The following untracked working tree files would be overwrittenby merge:     
 Library/Formula/argp-standalone.rb
 Library/Formula/cocot.rb 
Please move or remove them before you can merge. 
Aborting 
Updating e088818..5909e2c 
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

我发现有个博客文章讲述了一个人在安装Mountain Lion(我这周也做了)后遇到类似问题的经历。他解释了如何删除错误信息所指的文件。

I removed these files:
$ cd $(brew --prefix)
$ rm cocot.rb
However, removing these files didn't help with the brew update. Instead I had to manually update brew through git:
$ cd $(brew --prefix)
$ git fetch origin
$ git reset --hard origin/master
$ brew update
Already up-to-date.

假设这些指令是正确的(也许我不应该这样假设),我尝试按照这些指令并执行。
    $ cd $(brew --prefix)
    $ rm cocot.rb

然而,当我尝试删除cocot.rb时,它显示“文件不存在”。

有一件事我不确定的是cd $(brew --prefix)。这些是我要键入的确切单词还是我需要用什么替换prefix?cd成功了,所以我认为它是正确的——它将我移动到了/usr/local,但没有文件可供删除。/usr/local的内容如下:

Cellar              clamXav             git             mysql               var Library             doc             heroku              mysql-5.5.15-osx10.6-x86_64 README.md           etc             include             rvm bin             foreman             lib             share

无论如何,你知道我如何修复“brew update”吗?
更新:按照favoretti的说明删除文件并尝试chown -R <your_username> $(brew --prefix)/.git后,运行brew update时出现以下错误。
error: The following untracked working tree files would be overwritten by merge:
    Library/Aliases/gperftools
    Library/Aliases/hashdeep
    Library/Aliases/htop
    Library/Aliases/nodejs
    Library/Aliases/ocio
    Library/Aliases/oiio
    Library/Aliases/pgrep
    Library/Aliases/pkill
    Library/Aliases/qt4
    Library/Aliases/twolame
    Library/Aliases/wxwidgets
    Library/Contributions/cmds/brew-aspell-dictionaries
    Library/Contributions/cmds/brew-beer.rb
    Library/Contributions/cmds/brew-dirty.rb
    Library/Contributions/cmds/brew-graph
    Library/Contributions/cmds/brew-grep
    Library/Contributions/cmds/brew-leaves.rb
    Library/Contributions/cmds/brew-linkapps.rb
    Library/Contributions/cmds/brew-ls-taps.rb
    Library/Contributions/cmds/brew-man
    Library/Contributions/cmds/brew-md5-to-sha1
    Library/Contributions/cmds/brew-mirror-check.rb
    Library/Contributions/cmds/brew-pull.rb
    Library/Contributions/cmds/brew-readall.rb
    Library/Contributions/cmds/brew-server
    Library/Contributions/cmds/brew-services.rb
    Library/Contributions/cmds/brew-switch.rb
    Library/Contributions/cmds/brew-test-bot.rb
    Library/Contributions/cmds/brew-tests.rb
    Library/Contributions/cmds/brew-unpack.rb
    Library/Contributions/cmds/brew-which.rb
    Library/Contributions/cmds/git
    Library/Contributions/cmds/svn
    Library/ENV/4.3/apr-1-config
    Library/ENV/4.3/bsdmake
    Library/ENV/4.3/c++
    Library/ENV/4.3/c89
    Library/ENV/4.3/c99
    Library/ENV/4.3/cc
    Library/ENV/4.3/clang
    Library/ENV/4.3/clang++
    Library/ENV/4.3/cpp
    Library/ENV/4.3/g++
    Library/ENV/4.3/gcc
    Library/ENV/4.3/git
    Library/ENV/4.3/i686-apple-darwin11-llvm-g++-4.2
    Library/ENV/4.3/i686-apple-darwin11-llvm-gcc-4.2
    Library/ENV/4.3/ld
    Library/ENV/4.3/llvm-g++
    Library/ENV/4.3/llvm-g++-4.2
    Library/ENV/4.3/llvm-gcc
    Library/ENV/4.3/llvm-gcc-4.2
    Library/ENV/4.3/make
    Library/ENV/4.3/mig
    Library/ENV/4.3/sed
    Library/ENV/4.3/svn
    Library/ENV/4.3/xcrun
    Library/ENV/libsuperenv.rb
    Library/ENV/pkgconfig/leopard/libcrypto.pc
    Library/ENV/pkgconfig/leopard/libcurl.pc
    Library/ENV/pkgconfig/mountain_lion/libcurl.pc
    Library/ENV/pkgconfig/mountain_lion/libexslt.pc
    Library/ENV/pkgconfig/mountain_lion/libxml-2.0.pc
    Library/ENV/pkgconfig/mountain_lion/libxslt.pc
    Library/Formula/abcl.rb
    Library/Formula/abcmidi.rb
    Library/Formula/aiccu.rb
    Library/Formula/akka.rb
    Library/Formula/alac.rb
    Library/Formula/alure.rb
    Library/Formula/appledoc.rb
    Library/Formula/arangodb.rb
    Library/Formula/argp-standalone.rb
    Library/Formula/argtable.rb
    Library/Formula/autopano-sift-c.rb
    Library/Formula/avian.rb
    Library/Formula/avidemux.rb
    Library/Formula/avro-cpp.rb
    Library/Formula/aws-cloudsearch.rb
    Library/Formula/aws-sns-cli.rb
    Library/Formula/backupninja.rb
    Library/Formula/bact.rb
    Library/Formula/bam.rb
    Library/Formula/basex.rb
    Library/Formula/berkeley-db4.rb
    Library/Formula/bind.rb
    Library/Formula/blazeblogger.rb
    Library/Formula/bochs.rb
    Library/Formula/boost149.rb
    Library/Formula/bsdconv.rb
    Library/Formula/bsdmake.rb
    Library/Formula/buildapp.rb
    Library/Formula/bup.rb
    Library/Formula/byacc.rb
    Library/Formula/cadubi.rb
    Library/Formula/camellia.rb
    Library/Formula/casperjs.rb
    Library/Formula/ccextractor.rb
    Library/Formula/cconv.rb
    Library/Formula/cdo.rb
    Library/Formula/cdpr.rb
    Library/Formula/cgvg.rb
    Library/Formula/checkstyle.rb
    Library/Formula/chordii.rb
    Library/Formula/chruby.rb
    Library/Formula/cifer.rb
    Library/Formula/clhep.rb
    Library/Formula/cntlm.rb
    Library/Formula/cocot.rb
    Library/Formula/cogl.rb
    Library/Formula/collada-dom.rb
    Library/Formula/crash.rb
    Library/Formula/crossroads.rb
    Library/Formula/crosstool-ng.rb
    Library/Formula/css-crush.rb
    Library/Formula/csync.rb
    Library/Formula/ctemplate.rb
    Library/Formula/curlftpfs.rb
    Library/Formula/cutter.rb
    Library/Formula/cvsutils.rb
    Library/Formula/darkstat.rb
    Library/Formula/darner.rb
    Library/Formula/dart.rb
    Library/Formula/dasm.rb
    Library/Formula/debianutils.rb
    Library/Formula/dfc.rb
    Library/Formula/dgtal.rb
    Library/Formula/dhcping.rb
    Library/Formula/di.rb
    Library/Formula/dmtx-utils.rb
    Library/Formula/drip.rb
    Library/Formula/dsniff.rb
    Library/Fo
Aborting
Updating e088818..c1fbc29
Error: Failed while executing git pull  origin refs/heads/master:refs/remotes/origin/master

https://dev59.com/HWgv5IYBdhLWcg3wNuN5 - Dan K.K.
请查看Homebrew Core的官方README.md文件。不需要像一些旧答案建议的那样调整权限。还要检查您是否指向当前的官方源URL。更多信息请参见此答案:https://dev59.com/6GYq5IYBdhLWcg3w5Ui8#40599893?s=2|2.2654#40599893 - Kay V
12个回答

0

这应该可以工作。

1. cd `brew --prefix`
2. git fetch origin
3. git reset --hard origin/master
4. sudo brew update

就目前而言,在使用Homebrew时强烈不建议使用sudo。请注意,当您使用sudo命令输入某个命令时,Homebrew会提供警告,并且其他回答中的Down-votes 和@A5308Y也提供了有关为什么不建议使用sudo的FAQ链接;该FAQ的最新版本位于https://github.com/Homebrew/brew/blob/master/docs/FAQ.md#why-does-homebrew-say-sudo-is-bad- 您尝试过在不使用sudo的情况下按照步骤操作吗? - Kay V

0

这篇文章在我更新到El Capitan后帮了我很大的忙。在我的情况下,chown命令无法使用(“zsh:command not found: chown”),所以第一步是将以下行添加到我的.zshrc文件中:

export PATH="$PATH:/usr/sbin"

我已经尝试过几个更受欢迎的答案,所以我相当确定在我从博客文章中复制关键命令之前,git status已经显示为干净:

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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接