7

Like it is mentioned here https://docs.brew.sh/FAQ#how-do-i-uninstall-homebrew I typed
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)" but it doesn't seem to work...

When I type afterwards which brew it returns /usr/local/bin/brew

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

It displays :

/bin/bash: line 236: /opt/homebrew/bin/brew: No such file or directory Failed to locate Homebrew!

So I don't know what to do to uninstall brew.

My ultimate goal is to not getting this error when I try to install a brew package :

Error: Cannot install in Homebrew on ARM processor in Intel default prefix (/usr/local)! Please create a new installation in /opt/homebrew using one of the "Alternative Installs" from:
https://docs.brew.sh/Installation You can migrate your previously installed formula list with: brew bundle dump

I now have a Mac with Apple Silicon but I used to have a Intel Mac.

EDIT 1 : I took a quick look at the uninstall.sh script here https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh

It seems that my problem is induced by my os installation because I did it from an Intel-based MacOS time machine backup. The problem is the uninstall.sh script is programed to uninstall homebrew according to the current os. So this script can only uninstall the ARM homebrew that I need and can't uninstall the Intel homebrew I try to get rid of...

Maybe I should try to just change the line of code that detect I have a ARM CPU to make the script think I have a Intel-based Mac but I don't know if it could bring chaos in my computer...

I'm surprised there's not a lot of answers about this problem since I don't think I'm the only one to have switched from Intel-based Mac to ARM-based Mac with Time Machine.

EDIT 2 : I tried to uninstall Homebrew with a command of my own arch -x86_64 ./uninstall_brew.sh (I have no idea if it's not DANGEROUS) but I don't know if it worked well...

Here is the output of the command :

user@MacBook-Pro % arch -x86_64 ./uninstall_brew.sh
Warning: This script will remove:
/Users/user/Library/Caches/Homebrew/
/usr/local/Caskroom/
/usr/local/Cellar/
/usr/local/bin/brew -> /usr/local/bin/brew
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
/usr/local/share/info/dir: Permission denied
Warning: Failed to delete /usr/local/Caskroom
rm: /usr/local/Caskroom: Permission denied
Warning: Failed to delete /usr/local/Cellar
rm: /usr/local/Cellar: Permission denied
==> Removing empty directories...
Password:
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -name .DS_Store -delete
==> /usr/bin/sudo /usr/bin/find /usr/local/bin /usr/local/etc /usr/local/include /usr/local/lib /usr/local/opt /usr/local/sbin /usr/local/share /usr/local/var /usr/local/Caskroom /usr/local/Cellar /usr/local/Homebrew /usr/local/Frameworks -depth -type d -empty -exec rmdir {} ;
==> Homebrew uninstalled!
The following possible Homebrew files were not deleted:
/usr/local/.com.apple.installer.keep
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/git/
/usr/local/include/
/usr/local/lib/
/usr/local/man/
/usr/local/opt/
/usr/local/remotedesktop/
/usr/local/sbin/
/usr/local/share/
/usr/local/var/
You may wish to remove them yourself.
t.niese
  • 39,256
  • 9
  • 74
  • 101
DigitalRomance
  • 305
  • 2
  • 7
  • Does this answer your question? [How to uninstall homebrew?](https://stackoverflow.com/questions/23251665/how-to-uninstall-homebrew) – chenrui Jul 09 '22 at 03:22
  • The OP has a similar problem but the link given in the answer he validated is a 404 error. The given solution tells the answer I search is in the FAQ but I've looked carefully and I didn't find it. – DigitalRomance Jul 09 '22 at 17:27
  • Do you have permission on those folders? Can you delete them manually? – Vega Jul 09 '22 at 19:21
  • I have admin rights but I'm a bit afraid to use them in case it could be dangerous for the computer. – DigitalRomance Jul 09 '22 at 20:29
  • I mean to use admin rights with the uninstall.sh script in case it could uninstall important files. – DigitalRomance Jul 10 '22 at 09:07
  • You cannot uninstall without using your admin rights – Vega Jul 10 '22 at 15:15

3 Answers3

9

Try running: PATH=/usr/local/bin:$PATH arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"

Found the answer here: https://github.com/Homebrew/discussions/discussions/3437

  • 8
    For M1 I needed to tweak it like this: `PATH=/opt/homebrew:$PATH arch -arm64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"` – Starsky Oct 24 '22 at 11:12
  • @Starsky's tweak worked for me. Just a thing to note, might have to go into the `/opt/homebrew` folder and delete what the script wasn't able to delete. Had some folders left after the script ran – m1771vw Aug 22 '23 at 14:59
2

I encounter similar issue on my M1 MBP, and I found that changing the uninstall path in the script may work.

First, I download a local copy of the uninstalling script

curl -O https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh

Then run the script locally and set the path to /user/local(which is the default path of homebrew on intel Mac)

/bin/bash uninstall.sh --path=/usr/local

but it completed with 2 warnings I'm not sure what they are

Warning: Failed during: /usr/bin/sudo rmdir /usr/local
Warning: Homebrew partially uninstalled (but there were steps that failed)!
To finish uninstalling rerun this script with `sudo`.
The following possible Homebrew files were not deleted:
/usr/local/Cellar/
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/bin/
/usr/local/etc/
/usr/local/include/
/usr/local/lib/
/usr/local/opt/
/usr/local/sbin/
/usr/local/share/
/usr/local/texlive/
/usr/local/var/
You may wish to remove them yourself.

Either way, I delete those files manually.

(This is my first time to answer something on stack overflow. Hope this help!)

1

I faced the same problem. The solution is just to remove your git configuration from your mac.

Command: rm -rf ~/.gitconfig

After executing the command try to install brew. Command: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

After installing homebrew install the brew git command: brew install git then configure your GitHub profile.

Thank you.

bfontaine
  • 18,169
  • 13
  • 73
  • 107
Paroi
  • 11
  • 2