homebrew - Brew 更新失败 : untracked working tree files would be overwritten by merge

标签 homebrew

尝试使用 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

但是,当我尝试 rm cocot.rb 时,它说“文件不存在”

我不确定的一件事是 cd $(brew --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

最佳答案

您需要执行以下操作:

cd $(brew --prefix)
rm Library/Formula/argp-standalone.rb
rm Library/Formula/cocot.rb

然后执行

git fetch origin
git reset --hard origin/master
brew update

基本上,解释一下:

cd $(brew --prefix)

告诉cd将目录更改为任何 brew --prefix将输出。 如果您尝试执行 brew --prefix命令你应该看到以下行中的内容:

brew --prefix
/usr/local

因此,在这种情况下,该命令相当于 cd /usr/local 。 较新 brew版本在其安装前缀和Library/Formula/下有公式,因此您需要在其中查找那些过时/已更改的文件。

请注意,如果您出于特定原因(例如固定版本)自行更改了这些公式,此操作会将它们恢复为默认值,并可能产生不需要的效果。

@TedPennings 在评论中指出这对他有用,但他的顺序是:

  1. 将所有内容更改为 my_username:admin ,即sudo chown -R ted:admin $(brew --prefix)
  2. 运行上面的两个 git 命令,git fetch origingit reset --hard origin/master

关于homebrew - Brew 更新失败 : untracked working tree files would be overwritten by merge,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14113427/

相关文章:

macos - 尝试在 macOS Sierra 上安装 Homebrew 时出现 xcode-select 错误

c++ - ld : symbols not found for architecture x86_64, clang: 链接器命令失败

configuration - 在系统范围内安装 OPAM?

c++ - OSX - 用通过 Homebrew 安装的 4.9 替换 gcc 版本 4.2.1

nokogiri - 使用 rspec 时出错,安装 Homebrew 并卸载 MacPorts 后缺少库

xcode - brew install macvim 不适用于 "xcode-lite",即 xcode 的命令行工具?

Homebrew 在 macOS Sierra 上找不到 LFTP 公式

macos - 你如何显示 Homebrew 公式提供的所有文件?

ruby-on-rails - 重新启动 mac PG::ConnectionBad 后无法连接到 postgres

macos - 如何修复 Mac OSX 10.9 上的 `brew doctor` 错误(未找到 Cellar 和 Homebrew sbin 中未链接的小桶)?