I ran the following command on terminal (Mac El Capitan)
$ /usr/bin/ruby -e "$(curl -fsSL )"
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
13 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
Then remove the cellar and homebrew directories from /usr/local and re-try the installation.
- create a file named
run.sh - 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
- run the file using
sh run.sh
Or, just run all these commands manually one by one.
@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
Steps to fix it on Big Sur (2021):
git config --global user.email- Remove the cellar and homebrew directories from
/usr/local - Re-try the installation
Works for me on Big Sur.
- New home-brew will installed in
/opt/homebrew/folder. - If some errors happened at installation you need to reinstall all.
- Try to clean all trashes with
sudo rm -rf /opt/homebrew/command - Tested and It's worked (12 September 2021)
Also, may you need to configure git config --global user.email
just do this little code rm -fr $(brew --repo homebrew/core) # because you can't brew untap homebrew/core brew tap homebrew/core
Fastest and easiest way is to uninstall Homebrew by following command -
/bin/bash -c "$(curl -fsSL )"
and after this, fresh install of Homebrew by following command -
/bin/bash -c "$(curl -fsSL )"
To fix the issue on Monterey:
1. sudo rm -rf /opt/homebrew/
2. git config --global user.email
After executing the steps, try back the installation
On linux the default installation happens at /home/linuxbrew
Just delete the /home/linuxbrew: sudo rm -rf /home/linuxbrew
Make sure you disable any ISP related 'child safe' settings.
I've been pulling my hair out with this for the last few hours - turned out that it was my ISPs 'child safe' settings (recently switched to Virgin Media) Hope this helps someone who's tried all the above and still having problems.
Deleting /opt/homebrew directory worked for me.
I am using Macbook air M1
sudo rm -rf /usr/local/HomeBrew
sudo rm -rf /opt/homebrew/
// actuall command to install HomeBrew
/bin/bash -c "$(curl -fsSL )"
If it still doesn't work, try setting you email for git client
git config --global user.email
If you're using M1 mac, probably homebrew packages were installed in /opt/.
Try deleting packages like this:
sudo rm -rf /opt/homebrew/bin/brew \
rm -rf /opt/homebrew/share/doc/homebrew \
rm -rf /opt/homebrew/share/man/man1/brew.1 \
rm -rf /opt/homebrew/share/zsh/site-functions/_brew \
rm -rf /opt/homebrew/etc/bash_completion.d/brew \
rm -rf /opt/homebrew
worked for me. :)