Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew installation error: "not a valid ref: refs/remotes/origin/master"?

Tags:

macos

homebrew

I have tried to install Homebrew on macOS Monterey by following the instructions at https://brew.sh/.

But it resulted in:

error: Not a valid ref: refs/remotes/origin/master
Error: Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core failed!
fatal: invalid upstream 'origin/master'
Failed during: /opt/homebrew/bin/brew update --force --quiet

1

like image 898
Merry Avatar asked May 13 '26 14:05

Merry


1 Answers

I encountered this error on my brand new Macbook Pro with the M2 processor. What worked for me was removing the contents of the homebrew directory

rm -rf /opt/homebrew

Then running the uninstall script (its the same as the intall script on the homebrew except change the last part from install to uninstall. Assuming the link has not changed on the homebrew website I ran these two commands and it installed successfully.

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

You can run brew -v or brew doctor to check if your install is good.

like image 157
Ricky Avatar answered May 15 '26 05:05

Ricky