Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

brew tap facebook/fb results in Fetching error

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?

like image 268
Raptor Avatar asked Aug 26 '21 01:08

Raptor


Video Answer


1 Answers

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.

like image 94
friederbluemle Avatar answered Oct 19 '22 16:10

friederbluemle