Homebrew fatal: needed a single revision (MacOs Sierra)
Asked Answered
P

5

31

Not sure if this problem is related to upgrading to MacOs Sierra, but since that moment this error occurs when I run 'brew update'

→ brew update
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask...
To checkout master in /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask run:
  'cd /usr/local/Homebrew/Library/Taps/caskroom/homebrew-cask && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart...
To checkout master in /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart run:
  'cd /usr/local/Homebrew/Library/Taps/dart-lang/homebrew-dart && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0
Checking out v1.0.0 in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core...
To checkout master in /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core run:
  'cd /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core && git checkout master
fatal: Cannot update paths and switch to branch 'v1.0.0' at the same time.
Did you intend to checkout 'refs/tags/1.0.0' which can not be resolved as commit?
fatal: Needed a single revision
invalid upstream refs/tags/1.0.0

I tried running

cd $(brew --prefix) && git fetch && git reset --hard origin/master

But it gives me this error:

fatal: Not a git repository (or any of the parent directories): .git
Pythagoras answered 21/9, 2016 at 14:50 Comment(1)
I get this too, and I haven't upgraded to Sierra. I have however upgraded to Brew 1.0Corruptible
M
60

I had the same problem after upgrading to Sierra.

In addition to brew --prefix, which displays Homebrew’s install path, there’s also brew --repository, which displays where it’s .git directory is located.

man brew says that claims that “for standard installs, the prefix and repository are the same directory”. Either the man page is out of date or my install isn’t “standard”, but my prefix is /usr/local and my repository is /usr/local/Homebrew.

Using the same command but with cd $(brew --repository) worked for me:

cd $(brew --repository) && git fetch && git reset --hard origin/master
Mailand answered 21/9, 2016 at 14:59 Comment(8)
Full fix: cd $(brew --prefix)/Homebrew && git fetch && git reset --hard origin/masterAyers
AKA brew --repositoryRansom
Edited to add the full command and information about brew --repository. Thanks!Mailand
Thanks @thomasd, this has fixed the problem for me!Pythagoras
Homebrew recently (this week) migrated from /usr/local to /usr/local/Homebrew, and the docs may still be out of date.Tendon
This will also mess up scripts that source bash completions with (brew --prefix).Benzaldehyde
You should consider updating your answer to @YuriTkachenko comment.Syllabic
Looks like it's a know issue that will now fix itself. Just need to brew update again. Thanks to @raxacoricofallapatorius for pointing it out.Syllabic
F
3

The accepted answer didn't work for me. What worked was uninstalling homebrew and reinstalling it:

ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/uninstall)"
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew analytics off
Fleabitten answered 23/9, 2016 at 11:57 Comment(0)
L
1

This command fixed the error for me:

git -C $(brew --repository homebrew/core) checkout master
Lien answered 27/1, 2022 at 18:19 Comment(0)
I
0

Nothing really worked for me, I had to resort to uninstalling and reinstalling Brew:

# change to home directory to avoid other errors later
cd ~

# uninstall brew
rm -rf /usr/local/Cellar /usr/local/.git && cd ~ && brew cleanup

 # reinstall brew
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Interpretive answered 28/4, 2017 at 5:15 Comment(0)
T
0

Uninstall


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

And the reinstall.

Totipalmate answered 7/8, 2021 at 11:37 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.