brew tap facebook/fb results in Fetching error

1.7k views Asked by At

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?

1

There are 1 answers

1
friederbluemle On BEST ANSWER

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.