Merry
Merry

Reputation: 91

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

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

Upvotes: 9

Views: 7046

Answers (3)

Sourabh Shekhar
Sourabh Shekhar

Reputation: 167

This worked on M1.

 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
git config --global core.compression 0
git config --global http.postBuffer 1048576000
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Upvotes: 0

James Stanbridge
James Stanbridge

Reputation: 128

My error was after a failed previous install with WSL... so same on windows, only:

cd /home 
sudo rm -rf homebrew/

Upvotes: 0

Ricky
Ricky

Reputation: 369

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.

Upvotes: 18

Related Questions