Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

brew update fails #5128

Closed
lgw4 opened this Issue · 81 comments
@lgw4

Attempted to install Homebrew on a new machine today. brew update failed.

[lgw4@mike:~]$ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...

Press enter to continue
==> /usr/bin/sudo /bin/mkdir /usr/local
==> /usr/bin/sudo /bin/chmod g+w /usr/local
==> /usr/bin/sudo /usr/bin/chgrp staff /usr/local
==> Downloading and Installing Homebrew...
==> Installation successful!
[lgw4@mike:~]$ brew install git
==> Downloading http://kernel.org/pub/software/scm/git/git-1.7.4.4.tar.bz2
######################################################################## 100.0%
==> make prefix=/usr/local/Cellar/git/1.7.4.4 install
==> Downloading http://kernel.org/pub/software/scm/git/git-manpages-1.7.4.4.tar.bz2
######################################################################## 100.0%
==> Downloading http://kernel.org/pub/software/scm/git/git-htmldocs-1.7.4.4.tar.bz2
######################################################################## 100.0%
==> Caveats
Bash completion and emacs support have been installed.

The rest of the "contrib" folder has been copied to:
  /usr/local/Cellar/git/1.7.4.4/share/contrib
==> Summary
/usr/local/Cellar/git/1.7.4.4: 1054 files, 19M, built in 43 seconds
[lgw4@mike:~]$ brew update

Initialized empty Git repository in /usr/local/.git/
remote: Counting objects: 35243, done.
remote: Compressing objects: 100% (16168/16168), done.
remote: Total 35243 (delta 20557), reused 31835 (delta 18515)
Receiving objects: 100% (35243/35243), 4.78 MiB | 1.24 MiB/s, done.
Resolving deltas: 100% (20557/20557), done.
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
error: Untracked working tree file '.gitignore' would be overwritten by merge.

Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master
[lgw4@mike:~]$ brew update
error: The following untracked working tree files would be overwritten by checkout:
    .gitignore
    Library/Aliases/0mq
    Library/Aliases/Secret Rabbit Code
    Library/Aliases/alut
    Library/Aliases/android
    Library/Aliases/apache-activemq
    Library/Aliases/apache-fop
    Library/Aliases/aws-as
    Library/Aliases/aws-mon
    Library/Aliases/beanstalkd
    Library/Aliases/bjam
    Library/Aliases/bzr
    Library/Aliases/cowthink
    Library/Aliases/cpanm
    Library/Aliases/ctags-exuberant
    Library/Aliases/db
    Library/Aliases/dbus
    Library/Aliases/dejagnu
    Library/Aliases/eyeD3
    Library/Aliases/firefly
    Library/Aliases/fluidsynth
    Library/Aliases/fsa
    Library/Aliases/gearmand
    Library/Aliases/gnu-scientific-library
    Library/Aliases/google-go
    Library/Aliases/gs
    Library/Aliases/gtk
    Library/Aliases/gtypist
    Library/Aliases/hudson
    Library/Aliases/hugs
    Library/Aliases/ipsum
    Library/Aliases/jocr
    Library/Aliases/jslint
    Library/Aliases/lcms
    Library/Aliases/leg
    Library/Aliases/libav
    Library/Aliases/libcryptopp
    Library/Aliases/libgd
    Library/Aliases/libgeoip
    Library/Aliases/libjpeg
    Library/Aliases/libjpg
    Library/Aliases/liblabjackusb
    Library/Aliases/libmad
    Library/Aliases/libmcrypt
    Library/Aliases/liboggz
    Library/Aliases/libqrencode
    Library/Aliases/libtag
    Library/Aliases/libtasn
    Library/Aliases/mc
    Library/Aliases/mikmod
    Library/Aliases/mongo
    Library/Aliases/mp4box
    Library/Aliases/node.js
    Library/Aliases/nsis
    Library/Aliases/o-caml
    Library/Aliases/ocaml
    Library/Aliases/omake
    Library/Aliases/ooc
    Library/Aliases/openocd
    Library/Aliases/p4
    Library/Aliases/p4d
    Library/Aliases/pipeviewer
    Library/Aliases/pkgconfig
    Library/Aliases/postgres
    Library/Aliases/rbx
    Library/Aliases/ree
    Library/Aliases/saga
    Library/Aliases/shell-fm
    Library/Aliases/slang
    Library/Aliases/stax-sdk
    Library/Aliases/style
    Library/Aliases/svn
    Library/Aliases/ultima4
    Library/Aliases/ultima7
    Library/Aliases/umfpack
    Library/Aliases/urxvt
    Library/Aliases/usb-multiplex-daemon
    Library/Aliases/zmq
    Library/Contributions/brew_bash_completion.sh
    Library/Contributions/brew_fish_completion.fish
    Library/Contributions/brew_zsh_completion.zsh
    Library/Contributions/examples/brew-bottle.rb
    Library/Contributions/examples/brew-depstree.rb
    Library/Contributions/examples/brew-dirty.rb
    Library/Contributions/examples/brew-graph
    Library/Contributions/examples/brew-grep
    Library/Contributions/examples/brew-leaves.rb
    Library/Contributions/examples/brew-linkapps.rb
    Library/Contributions/examples/brew-man
    Library/Contributions/examples/brew-missing.rb
    Library/Contributions/examples/brew-pull.rb
    Library/Contributions/examples/brew-readall.rb
    Library/Contributions/examples/brew-server
    Library/Contributions/examples/brew-switch.rb
    Library/Contributions/examples/brew-upgrade.rb
    Library/Contributions/examples/brew-which.rb
    Library/Contributions/manpages/brew-man.1.md
    Library/Contributions/manpages/brew.1.md
    Library/Formula/a2ps.rb
    Library/Formula/a52dec.rb
    Library/Formula/aacgain.rb
    Library/Formula/aalib.rb
    Library/Formula/aamath.rb
    Library/Formula/aardvark_shell_utils.rb
    Library/Formula/abcde.rb
    Library/Formula/abfind.rb
    Library/Formula/abiword.rb
    Library/Formula/abnfgen.rb
    Library/Formula/abook.rb
    Library/Formula/abuse.rb
    Library/Formula/ack.rb
    Library/Formula/activemq.rb
    Library/Formula/adamem.rb
    Library/Formula/adobe-air-sdk.rb
    Library/Formula/adplug.rb
    Library/Formula/advancecomp.rb
    Library/Formula/aescrypt.rb
    Library/Formula/afflib.rb
    Library/Formula/afsctool.rb
    Library/Formula/aften.rb
    Library/Formula/aget.rb
    Library/Formula/aggregate.rb
    Library/Formula/agrep.rb
    Library/Formula/aircrack-ng.rb
    Library/Formula/akonadi.rb
    Library/Formula/aldo.rb
    Library/Formula/algol68g.rb
    Library/Formula/alpine.rb
    Library/Formula/android-ndk.rb
    Library/Formula/android-sdk.rb
    Library/Formula/angband.rb
    Library/Formula/ansifilter.rb
    Library/Formula/antiword.rb
    Library/Formula/antlr.rb
    Library/Formula/aoeui.rb
    Library/Formula/apachetop.rb
    Library/Formula/apc.rb
    Library/Formula/apg.rb
    Library/Formula/apgdiff.rb
    Library/Formula/aplus.rb
    Library/
Aborting
Error: Failure while executing: git checkout -q master 
[lgw4@mike:~]$

brew doctor is fine.

[lgw4@mike:~]$ brew doctor
Your OS X is ripe for brewing.
Any troubles you may be experiencing are likely purely psychosomatic.
[lgw4@mike:~]$ 

brew --env and brew --config look fine, too.

[lgw4@mike:~]$ brew --env ; brew --config
CC: /usr/bin/cc => /usr/bin/gcc-4.2
CXX: /usr/bin/c++ => /usr/bin/c++-4.2
LD: /usr/bin/cc => /usr/bin/gcc-4.2
CFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
CXXFLAGS: -O3 -march=core2 -msse4.1 -w -pipe
MAKEFLAGS: -j2
HOMEBREW_VERSION: 0.8
HEAD: ce00963228188ba7c0475646a450c3d06bf48a99
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
HOMEBREW_REPOSITORY: /usr/local
HOMEBREW_LIBRARY_PATH: /usr/local/Library/Homebrew
Hardware: dual-core 64-bit penryn
OS X: 10.6.7
Kernel Architecture: i386
Ruby: 1.8.7-174
/usr/bin/ruby => /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
Xcode: 3.2.6
GCC-4.0: build 5494 
GCC-4.2: build 5666 
LLVM: build 2335 
MacPorts or Fink? false
X11 installed? true
[lgw4@mike:~]$ 
@MindTooth

This is a fresh install?

$ cd /usr/local

$ git fetch origin

$ git reset --hard origin/master

Can you tell how this outputs?

@lgw4
[lgw4@mike:~]$ cd /usr/local/
[lgw4@mike:local]$ git fetch origin
fatal: 'origin' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
[lgw4@mike:local]$ git reset --hard origin/master
fatal: ambiguous argument 'origin/master': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
[lgw4@mike:local]$ 
@MindTooth

$ cd /usr/local/

$ git remote add origin git://github.com/mxcl/homebrew.git

Then run the above.

@lgw4

This seems to have fixed the problem.

[lgw4@mike:local]$ git remote add origin git://github.com/mxcl/homebrew.git
[lgw4@mike:local]$ git fetch origin
remote: Counting objects: 50, done.
remote: Compressing objects: 100% (35/35), done.
remote: Total 46 (delta 15), reused 37 (delta 9)
Unpacking objects: 100% (46/46), done.
From git://github.com/mxcl/homebrew
 * [new branch]      gh-pages   -> origin/gh-pages
 * [new branch]      master     -> origin/master
[lgw4@mike:local]$ git reset --hard origin/master
HEAD is now at aff8ce3 Gearmand 0.20
[lgw4@mike:local]$ brew update
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
Already up-to-date.

Any idea what caused the problem?

@MindTooth

Sorry, I really don't. Maybe something broke the installation before it finished.

@lgw4 lgw4 closed this
@samueljohn

Well, I'd like to re-open. I have a fresh install (deleted /usr/local completely) and the same issue.
And Igw4's hint fixed the problem for me too. You can easily try that by mv your /usr/local to /usr/__my_precious_local and set up an new brew as described on the homepage.

samuel@localhost:~ $ ruby -e "$(curl -fsSLk https://gist.github.com/raw/323731/install_homebrew.rb)"
==> This script will install:
/usr/local/bin/brew
/usr/local/Library/Formula/...
/usr/local/Library/Homebrew/...

Press enter to continue
==> /usr/bin/sudo /bin/mkdir /usr/local
==> /usr/bin/sudo /bin/chmod g+w /usr/local
==> /usr/bin/sudo /usr/bin/chgrp staff /usr/local
==> Downloading and Installing Homebrew...
==> Installation successful!
samuel@localhost:~ $ brew update
Please `brew install git' first.
samuel@localhost:~ $ brew install git
==> Downloading http://kernel.org/pub/software/scm/git/git-1.7.4.4.tar.bz2
File already downloaded and cached to /Users/samuel/Library/Caches/Homebrew
==> make prefix=/usr/local/Cellar/git/1.7.4.4 install
==> Downloading http://kernel.org/pub/software/scm/git/git-manpages-1.7.4.4.tar.
File already downloaded and cached to /Users/samuel/Library/Caches/Homebrew
==> Downloading http://kernel.org/pub/software/scm/git/git-htmldocs-1.7.4.4.tar.
File already downloaded and cached to /Users/samuel/Library/Caches/Homebrew
==> Caveats
Bash completion and emacs support have been installed.

The rest of the "contrib" folder has been copied to:
/usr/local/Cellar/git/1.7.4.4/share/contrib
==> Summary
/usr/local/Cellar/git/1.7.4.4: 1054 files, 19M, built in 68 seconds
samuel@localhost:~ $ brew update

Initialized empty Git repository in /usr/local/.git/
remote: Counting objects: 35417, done.
remote: Compressing objects: 100% (16342/16342), done.
remote: Total 35417 (delta 20687), reused 31821 (delta 18515)
Receiving objects: 100% (35417/35417), 4.83 MiB | 213 KiB/s, done.
Resolving deltas: 100% (20687/20687), done.
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
error: Untracked working tree file '.gitignore' would be overwritten by merge.

Error: Failed while executing git pull http://github.com/mxcl/homebrew.git master
samuel@localhost:~ $ cd /usr/local
samuel@localhost:/usr/local $ brew update
error: The following untracked working tree files would be overwritten by checkout:
.gitignore
Library/Aliases/0mq
Library/Aliases/Secret Rabbit Code
 [snip]
@adamv adamv reopened this
@amarshall

@samueljohn by "deleted /usr/local completely" do you mean deleted all its contents or deleted the actual folder?

@samueljohn

@amarshall I mean mv /usr/local /usr/__local, so there is no /usr/local

@lgw4

I agree this is still happening. I tried another fresh Homebrew install on a fresh 10.6.7 install with Xcode 3.2.6 and am still seeing this error. Sure, the steps given by MindTooth above fix the problem, but the problem persists. Might make someone give up and go back to MacPorts (okay, sorry for the troll bait, but still…).

@lgw4 lgw4 closed this
@lgw4 lgw4 reopened this
@samueljohn

@Igw4: Indeed, I am coming from MacPorts and I think homebrew is really cool (and the first reason to learn about ruby, even if I am a python lover).

@lombers

This issue has also happened for me on 10.6.7 and xcode 3.2.6 on a fresh install. The above steps posted seem to fix the issue...

@adamv
Owner

If this is happening in fresh installs, the "brew update" is probably broken in some way, and the other maintainers will need to jump in.

(I don't use "brew update" personally, I always get fetch.)

@digitalcardboard

Happened to me twice, once on a MacBook w/ 10.6.7., another on a Hackintosh with 10.6.6. Both coming from MacPorts, if that makes any difference. Adding the origin repo manually seems to have fixed it, but it's a little funky. Otherwise things are working great!

@adamv
Owner

@mikemcquaid @mxcl - something fishy here? I don't use "brew update" so I dunno.

@digitalcardboard

@adamv if you don't use 'brew update' then what do you use? All the docs I'm reading show that command, and I'm a junkie for updates. So far, it's still much better than that other package manager, but the extra setup to get updates to work is kinda funky.

@mikemcquaid
Owner

I never really use brew update either. I just use git pull instead. Perhaps we should encourage Xcode 4 people (which these guys aren't) to just do a git checkout. I guess @mxcl would know best about the installation script.

@samueljohn

I dont have Xcode 4.
But I have had that issue.
I think brew update is important to work, because it is more convenient, clear and important for non git power-users.

@digitalcardboard

@samueljohn Agreed, it's much clearer.

The install script (per the wiki) doesn't initialize a .git (understandably, because we may not have git installed at that point) so when brew update is run for the first time, it complains about all them untracked working tree files. I'd love for the brew doctor to be able to make these kinds of boo-boos better.

For the time being, I've linked the wiki to this issue, so that other people are aware.

@jacknagel
Collaborator

re: the installer not doing a git init, perhaps in the future, when Xcode 4 is a bit more widespread, the install instructions could suggest that Xcode be installed first, and then the installer could safely run git commands since git is included in the Xcode 4 package. Just a thought.

@samueljohn

@jacknagel: Sure, but Xcode 4 costs (a bit).
The issue here is not directly related to a missing git, because I first did a brew install git and then brew update if no /usr/local is there at all.

@jacknagel
Collaborator

Right. But the installer script just untars the homebrew tarball into /usr/local, and as @digitalcardboard noted, when brew update is run for the first time, it runs git init, and then after pulling down from the github repo it tries to checkout the master branch which results in all the conflicts that you are seeing. If there was a system git (as there is with XCode 4 pre-installed), it could be used for the main installation and installing from the tarball could be a fallback.

(Aside: Like you said, XCode 4 isn't free but I have a feeling it might still be included on the Lion install discs, and only cost for people who get Lion via the App Store. Either way, eventually it will become the norm for devs to have XCode 4, or another way of getting the toolchain will emerge.)

Edit: my point related to this issue is that brew update should probably make git ignore the fact that it is overwriting a bunch of files in /usr/local when it tries to checkout master for the first time.

@matrixagent

Well, this is pretty annoying. Because I actually am not able to get homebrew fully working at the moment. I only discovered this issue after deciding to reinstall because of another problem which I can now reproduce and I think might be related to this one.

The steps (add remote, fetch, hard reset) to fix the failing update do work, but at least for me have a nasty side effect. After applying them, whenever I run brew info on any formula (I tried a dozen, both ones I have installed and ones I never before did anything with), the URL in the last line, which should be

http://github.com/mxcl/homebrew/commits/master/Library/Formula/...

is instead returned as

http://github.com/matrixagent/homebrew/commits/master/Library/Formula/...

i.e. it has my github username instead of @mxcl's and of course it does not exist.

brew install works fine, but still, not being able to use brew info --url is pretty annyoing, and the whole thing just feels horribly broken.

I have never forked homebrew, so I have not the slightest idea why this is happening.
The reason why I decided reinstalling homebrew was because all of a sudden all the URLs were wrong. So this also happened without the clean install ahead, I can't exactly say when or how, however.

As I said, this is reproducable. I also moved my old /usr/local away so that it didn't even exist before installing homebrew.
Directly after installing, brew info gives the correct URL, but update will fail. After applying the fixing steps from this thread, brew update will work, but all formulae have the wrong URL. I retried this 3 times, same result every time.

10.6.7, latest Xcode 3. I never had MacPorts or anything else on this system.

@jacknagel
Collaborator

It looks to me like the info command is broken, as it is putting together the url by looking for a username in your global git config. Didn't notice it until now, but the exact same thing happens on my installation.

@matrixagent

Would be weird however that this only started happening a few days ago then. Was brew info modified?
A friend of mine who also has his username set in his global git config can't reproduce it.

@jacknagel
Collaborator

Yeah, it's weird. On first glance I'm not even sure why brew info needs to know my github username, but it does default to mxcl if it can't locate github.user in the global .gitconfig (i.e., if I comment out that line in my gitconfig it provides the correct links).

Looking at the history, that bit of code has been there at least since refactor was merged, if not before.

@jacknagel
Collaborator

@adamv: can you provide some insight here re: brew info?

@adamv
Owner

If someone has Homebrew forked, and is working in a branch, then "brew info" should show that branch rather than mxcl's upstream. Because otherwise a bug report might contain a link to a user-added formula that doesn't exist in mxcl.

But it's quite likely that there's a bug in the current code. Except that it ought not matter for brew update, which is what the original bug title is about here.

@adamv
Owner

But again, I don't use brew update personally, so I'm not sure what the problem/fix here is.

@jacknagel
Collaborator

I think the issue with brew update is that when it is executed for the first time, it runs git init and then git pull from mxcl/master. But the installer script just unpacks the tarball into /usr/local, so when git pull is executed, there are a bunch of untracked files in the way.

Correct me if I'm wrong on any of that.

As far as brew info, the current code uses github.user even if that person has never forked Homebrew. So that probably warrants an issue of its own.

@mxcl mxcl was assigned
@digitalcardboard

@jacknagel That's what I see as well (re: the original brew update issue)

Running git fetch origin isn't documented anywhere for the casual user, doesn't give the info about new/updated formulae, and can't be ran ran until you've got a git repo locally anyway.

@wondersloth

I had this problem and this thread fixed it. Thanks!

@UniK

@wondersloth
Can you provide information on how exactly you've solved this issue?

@mikemcquaid
Owner

I think we need to fix the installer. @mxcl, thoughts?

@burfield

I'm having this same issue. @wondersloth can you comment on what you did to fix it? I have followed the steps above and I'm still having the same problem.

@jacknagel
Collaborator

@burfield: What happens if you do:

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

and then run brew update?

@jfmercer

I tried all of the above suggestions. Nothing worked. So I just uninstalled Homebrew along with some of my favorite Homebrew-ed programs: wget, pianobar, nmap, etc. After reinstall, everything is working fine.

@jacknagel
Collaborator

Doing some cursory research, I think this issue might have been introduced by a change in git as of version 1.7.4.4. From the release notes:

"git pull" into an empty branch should have behaved as if
fast-forwarding from emptiness to the version being pulled, with
the usual protection against overwriting untracked files.
@jacknagel
Collaborator

I think this could be fixed in several ways, but it's really a matter of what the maintainers deem to be the correct behavior. For example, brew update could be modified so that it does git checkout -f only the first time it is run, and after that behaves as it does currently. But it would be good to have this addressed because it seems to be affecting a lot of new installs.

@burfield

@jacknagel for some reason that worked this time. Those are the same steps I tried before with no luck.

Seems good for now.

Thanks.

@wondersloth

I basically did what @jacknagel did. Good to know it's working for you now.

@fibric

oh I wrote a comment to an other issue. there are many Issues related to this one here.
Here is my comment:
#5246 (comment)

@mikemcquaid
Owner

In summary, later versions of Git means git pull won't overwrite the existing files unless you ask it to be forced. The installer needs to be fixed and only @mxcl can edit the Gist (unless we fork it and edit the wiki page). A simple workaround is to do git checkout -f in the mean time.

@jacknagel
Collaborator

Actually I think brew update is really what is broken by the later versions of Git, since the installer just unpacks the tarball and doesn't make any assumptions about an existing installation of git.

@soupmatt

I opened a pull request with a fix for this issue. See #5483.

@soupmatt

I have found that @jacknagel's suggestion of

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

works well. You can also do this:

cd `brew --prefix`
git fetch https://github.com/mxcl/homebrew.git
git reset --hard FETCH_HEAD

This is the same thing, but without adding a remote.

@anbotero

Thank you very much for this fix. I just made an implode on brew because I had a whole bunch of software I no longer needed, and seemed to have trouble with MySQL, but when I was going to reinstall, I hit a wall with this.

Thanks!

@galtenberg

I was able to add origin and fetch origin, but when doing the reset, this happened:

local/git reset --hard origin/master
error: unable to unlink old 'bin/brew' (Permission denied)
fatal: Could not reset index file to revision 'origin/master'.

Should I just rm -rf ?

@soupmatt

You'll have to check the permissions on the /usr/local directory. You may have installed homebrew as another user or root. Make sure you have write access to the directory.

@MindTooth

My fixbrew command:

alias fixbrew='sudo chown -R $USER /usr/local'

NB! If you have MySQL installed, you need to reset the database files to mysql:mysql afterwards.

@galtenberg

Thanks friends -- I'm all set now

(UPDATE: Although wouldn't recommend the across-the-board chown of /usr/local -- mysql is definitely not happy now)

@kenn

Same here, with a fresh OSX 10.6.7 and Xcode 3.2.6. This thread saved the day.

@mikemcquaid mikemcquaid was assigned
@arubis

Non-fresh brew just fixed with this thread too. Seriously, seriously thanks. I didn't even know hb dropped a .git in /usr/local.

@mxcl mxcl was assigned
@Frobitz

Had this problem on a completely fresh install of OS X 10.6.7 as well. Many thanks to Mindtooth for the solution.

@MindTooth

Glad I could be of service ;)

@RyanBalfanz

@mwcmpbll, I can't complete any of the steps you suggested at #5128 (comment).

I think this is because I installed homebrew as my admin user (#5128 (comment)). Some of the files in /usr/local/.git are root:staff, some admin:staff and some ryan:staff.

Has anybody noticed any of the issues in this thread using an admin user and a regular user like I have? Is it not suggested to do so for any reason? My core issues seem (cannot brew update) related but I'm not sure if they're related.

@soupmatt

Check out @MindTooth's fix for if you installed brew as root: #5128 (comment)

@MindTooth

Be aware! I've been noticed that my wonder command can make MySQL databases useless. Since they depend on mysql:mysql.

If you have MySQL databases under /usr/local before sure to CHOWN them back later.

@fallwith

I too am still unable to use "brew update". Based on the (great!) information provided by this thread, I have created an alias. I can now successfully run "brewupdate" instead of "brew update".

alias brewupdate="opwd=`pwd` && cd `brew --prefix` && git init && git fetch https://github.com/mxcl/homebrew.git && git reset --hard FETCH_HEAD && cd $opwd"
@MindTooth

Another try:

$ cd brew --prefix
$ git init
$ git remote add -f -t master -m master origin git://github.com/mxcl/homebrew.git
$ git reset --hard origin/HEAD

@mecca831

Same problem here after a clean install. I was googling for solutions yesterday and followed this article:
http://stackoverflow.com/questions/5440017/homebrew-is-generating-two-warnings

Just enter:

cd /usr/local && git reset --hard HEAD

Then brew update seems to work. Don't know if there's any side effect.

@victorhooi

heya,

Hmm, I'm encoutering this issue as well:

192-168-1-29:local victorhooi$ brew update

Initialized empty Git repository in /usr/local/.git/
remote: Counting objects: 38403, done.
remote: Compressing objects: 100% (17202/17202), done.
remote: Total 38403 (delta 22941), reused 34248 (delta 20619)
Receiving objects: 100% (38403/38403), 5.30 MiB | 450 KiB/s, done.
Resolving deltas: 100% (22941/22941), done.
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
error: Untracked working tree file '.gitignore' would be overwritten by merge.

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

I then tried mecca831's instructions from above, and got an error about /usr/local/Cellar:

192-168-1-29:local victorhooi$ cd /usr/local && git reset --hard HEAD
HEAD is now at 9c56fd8 antlr: match Homebrew style guide
192-168-1-29:local victorhooi$ brew update
From http://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
Error: No such file or directory - /usr/local/Cellar
192-168-1-29:local victorhooi$

Not sure why exactly this is happening?

Hmm, this issue seems to have been going on for a while...lol. Is there a definitive fix for it?

Cheers,
Victor

@soupmatt

Try the fix here: #5128 (comment)

@soupmatt soupmatt referenced this issue from a commit
@soupmatt soupmatt Fix for issue #5128
do fetch and reset --hard to maintain the same functionality as before.
0c76b73
@mxcl
Collaborator

OK, so for further information. This started happening with Git 1.7.4 or 1.7.5, as it doesn't happen with the Xcode 4 provided Git which is 1.7.3.

@mxcl mxcl closed this issue from a commit
@mxcl mxcl Fix first `brew update` with Git 1.7.4+; Fixes #5128
Behaviour for git checkout was changed such that the update would fail because it refused to checkout files on to existing files in the working directory.

This was bad behaviour anyway, we should make efforts to keep any local modifications to the Homebrew checkout. Everything is neatly resolved if we just do a --soft reset.

Closes #6017.
8bec9b1
@mxcl mxcl closed this in 8bec9b1
@mxcl
Collaborator

Those still suffering can:

git fetch git://github.com/mxcl/homebrew.git
git reset FETCH_HEAD
brew update
@harking harking referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@dtan

i followed brew doctors instructions and made sure these folders were chowned under my user (but left the group the same):

/usr/local/include
/usr/local/share
/usr/local/share/man
/usr/local/share/man/man1
@bilke bilke referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@cyberdelia cyberdelia referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@cyberdelia cyberdelia referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@mistydemeo mistydemeo referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@godfat godfat referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@gjherbiet gjherbiet referenced this issue from a commit in gjherbiet/homebrew
Guillaume-Jean Herbiet Merge branch 'master' of http://github.com/mxcl/homebrew
* 'master' of http://github.com/mxcl/homebrew: (104 commits)
  Don’t error out if the Cellar doesn’t yet exist
  Fix first `brew update` with Git 1.7.4+; Fixes #5128
  refactor `update` command to use git diff instead of parsing `pull` output
  enable updater tests to be run on their own
  ejabberd: add odbc
  sleuthkit 3.2.2
  tor: add startup plist
  tabix 0.2.5
  macvin: add --enable-clipboard option
  raptor 2.0.2; replaces 1.4.x
  emacs: Fix fullscreen patch for head
  emacs: allow sRGB colors in Cocoa build
  emacs: add command-line caveats to cocoa builds
  redis 2.2.10
  bulk_extractor 0.7.24
  hadoop: also install map reduce streaming
  hbase 0.90.3
  jenkins 1.415
  antlr: match Homebrew style guide
  antlr 3.3
  ...
fc705f3
@cschep

This exact thing happened to me today on a fresh install of Lion from a restore disc. Xcode 4.1 installed, ran the default install instructions, brew update exploded. Should this be reopened?

@dylanvee

@cschep, I had the exact same experience as you. Unfortunately I forget exactly what I did to fix it.

@cschep

@dylanvee I did the following that was suggested above:

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

I had to sudo the git reset command though.. too weird.

@mxcl
Collaborator

No, it was a different bug, which we fixed yesterday. if after a working update it persists please open a new ticket.

@idev

Don't know if this also is noteworthy, I had the same issue but was on git 1.6.2, updated git to the latest version and now brew update works for me.

@Sharpie Sharpie referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@dylanvee

@idev I had this issue after installing Homebrew and then using it to install the latest git.

@Sharpie Sharpie referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@Sharpie Sharpie referenced this issue from a commit in Sharpie/homebrew
@mxcl mxcl Fix first `brew update` with Git 1.7.4+; Fixes #5128
Behaviour for git checkout was changed such that the update would fail because it refused to checkout files on to existing files in the working directory.

This was bad behaviour anyway, we should make efforts to keep any local modifications to the Homebrew checkout. Everything is neatly resolved if we just do a --soft reset.

Closes #6017.
978c1af
@codykrieger codykrieger referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@trynity trynity referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@jleedev jleedev referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@etehtsea etehtsea referenced this issue from a commit in etehtsea/homebrew
@mxcl mxcl Fix first `brew update` with Git 1.7.4+; Fixes #5128
Behaviour for git checkout was changed such that the update would fail because it refused to checkout files on to existing files in the working directory.

This was bad behaviour anyway, we should make efforts to keep any local modifications to the Homebrew checkout. Everything is neatly resolved if we just do a --soft reset.

Closes #6017.
8946fbc
@conatus

Permission fix fixed this for me.

sudo chown -R $USER /usr/local' - as above.

Before that I blundered through the git fetch routine.

@martyvona

I was seeing similar issues with brew update failing; for me this appears to have been due to using an old 1.6.x version of git, which apparently has compatibility issues now with github when using http (403 errors). The trick was that I had installed git via brew. This is what worked for me

cd `brew --prefix`
rm -rf .git
git remote add origin git://github.com/mxcl/homebrew.git
git fetch origin
git reset --hard origin/master
brew update
brew install git
@benhoxie

martyvona's solution worked for me, with one additional line: after rm -rf .git, you need to initialize git with:
git init

@stonegao

Fresh install on Mac OS X 10.8 still fails

ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)

remote: Counting objects: 77266, done.
remote: Compressing objects: 100% (37198/37198), done.
remote: Total 77266 (delta 52645), reused 61373 (delta 39257)
Receiving objects: 100% (77266/77266), 10.99 MiB | 798 KiB/s, done.
Resolving deltas: 100% (52645/52645), done.
From https://github.com/mxcl/homebrew
 * branch            master     -> FETCH_HEAD
error: Untracked working tree file '.gitignore' would be overwritten by merge.
Failed during: xcrun git pull origin master
@jasonbosco

@stonegao It's a permission issue. /usr/local should be owned by the current user.

$ sudo chown -R $USER /usr/local

Remove existing installation (which just failed):

$ rm -rf /usr/local/*
$ rm -rf /usr/local/.*

And then re-install

$ ruby <(curl -fsSkL raw.github.com/mxcl/homebrew/go)
@mcandre

@jasonbosco Thanks! Works for me!

Specs:

  • Homebrew
  • Mac OS X 10.8.2
  • MacBook Pro 2009
@snakeyroc3 snakeyroc3 referenced this issue from a commit in snakeyroc3/homebrew
@mxcl mxcl Fix first `brew update` with Git 1.7.4+; Fixes #5128
Behaviour for git checkout was changed such that the update would fail because it refused to checkout files on to existing files in the working directory.

This was bad behaviour anyway, we should make efforts to keep any local modifications to the Homebrew checkout. Everything is neatly resolved if we just do a --soft reset.

Closes #6017.
45a6b00
@snez

cd /usr/local
git reset head --hard
git clean -f
brew update <- will work

@ShujiaHuang

Thanks @snez your suggestion is work!

@scottspeidel

This worked for me:

$ cd `brew --prefix`
$ git remote add origin https://github.com/Homebrew/homebrew.git
$ git fetch origin
$ git reset --hard origin/master
$ brew update

Already up-to-date.

found here: http://stackoverflow.com/questions/9370552/brew-update-failure-while-executing-git-checkout

@jacknagel jacknagel locked and limited conversation to collaborators
@mxcl mxcl was unassigned by jacknagel
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Something went wrong with that request. Please try again.