9

I try to update Homebrew as usual. Recently when I issue the command brew update, the following error occurs:

Error: Fetching /usr/local/Homebrew/Library/Taps/facebook/homebrew-fb failed!

The Tap is associated with the software Buck, which I need for development.

I further investigate the issue by following the installation instruction in the Buck official website, I issue the command again:

% brew tap facebook/fb
==> Unshallowing facebook/fb
fatal: couldn't find remote ref refs/heads/master
Error: Failure while executing; `git fetch --unshallow` exited with 128.

Apparently, the Git source has problems. I try to "untap" it:

% brew untap facebook/fb
Error: Refusing to untap facebook/fb because it contains the following installed formulae or casks:
buck

No luck. How can I resolve this problem?

Raptor
  • 53,206
  • 45
  • 230
  • 366
  • Try https://stackoverflow.com/questions/65399729/invalid-formula-usr-local-homebrew-library-taps-facebook-homebrew-fb-buck-rb – alvas Aug 26 '21 at 03:39
  • 1
    But seems like it's back https://github.com/facebook/idb/issues/646#issuecomment-897588288 – alvas Aug 26 '21 at 03:39

1 Answers1

27

This error is the result of Facebook renaming the branch master to main.

To fix this, first change into Homebrew's local tap folder:

cd /usr/local/Homebrew/Library/Taps/facebook/homebrew-fb

Then, run the following Git commands to update the local repo:

git branch --unset-upstream
git config remote.origin.fetch '+refs/heads/main:refs/remotes/origin/main'
git fetch --prune origin
git branch -m main
git branch -u origin/main
git remote set-head origin -a

Finally, remove the no longer needed master ref (optional):

rm .git/refs/remotes/origin/master

That's it, you should now be able to successfully run brew update.

friederbluemle
  • 33,549
  • 14
  • 108
  • 109