Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Homebrew install: Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1

I ran the following command on terminal (Mac El Capitan)

$ /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

and got the following error message:

Failed during: git fetch origin master:refs/remotes/origin/master -n --depth=1

Additionally tried:

sudo chown $(whoami):admin /usr/local && sudo chown -R $(whoami):admin /usr/local

then the two commands above.

Any idea how to install Homebrew?

brew is not recognized and ruby version 2.0.0, git version 2.7.4

like image 915
anm Avatar asked Oct 03 '16 16:10

anm


5 Answers

After a few hours of research and brute force I learned the issue was due to git not being configured properly. Some articles suggested downgrading your git or reinstalling all together. However, I resolved the issue just by adding the following

git config --global user.email [email protected]

Then remove the cellar and homebrew directories from /usr/local and re-try the installation.

like image 153
anm Avatar answered Nov 17 '22 15:11

anm


  1. create a file named run.sh
  2. add this:
rm -rf /usr/local/bin/brew
rm -rf /usr/local/share/doc/homebrew
rm -rf /usr/local/share/man/man1/brew.1
rm -rf /usr/local/share/zsh/site-functions/_brew
rm -rf /usr/local/etc/bash_completion.d/brew
rm -rf /usr/local/Homebrew
  1. run the file using sh run.sh

Or, just run all these commands manually one by one.

like image 34
Ash Singh Avatar answered Nov 17 '22 17:11

Ash Singh


@ashdaily commands worked for me, addindg sudo on last command and then executing also the @Sinux command too:

rm -rf /usr/local/bin/brew
rm -rf /usr/local/share/doc/homebrew
rm -rf /usr/local/share/man/man1/brew.1
rm -rf /usr/local/share/zsh/site-functions/_brew
rm -rf /usr/local/etc/bash_completion.d/brew
sudo rm -rf /usr/local/Homebrew
rm -rf /opt/homebrew
like image 39
Ricardo Barroso Avatar answered Nov 17 '22 16:11

Ricardo Barroso


Fastest and easiest way is to uninstall Homebrew by following command -

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

and after this, fresh install of Homebrew by following command -

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
like image 10
Himanshu Gupta Avatar answered Nov 17 '22 15:11

Himanshu Gupta


Steps to fix it on Big Sur (2021):

  1. git config --global user.email [email protected]
  2. Remove the cellar and homebrew directories from /usr/local
  3. Re-try the installation

Works for me on Big Sur.

like image 7
Lucas Avatar answered Nov 17 '22 17:11

Lucas