Skip to content

Uninstall fails due to not enought permission. #1134

Description

@Fricsion

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • your problem was from running the official install or uninstall script?
  • you carefully read Git checkout or network failures and confirmed that the problem is not caused by your connection to GitHub or curl configuration?
  • [-] after installation: ran brew config and brew doctor and included their output with your issue? If you couldn't install: provided your OS version with the output of your issue? (not applicable since it's uninstallation process)

What you were trying to do (and why)

I was trying to achieve migration from x64 to arm since I'm on Apple silicon mac.

What happened (include command output)

The official uninstall script asked password right after when it needed the most.
And it recommended using sudo, which also failed because it no longer detect homebrew is there.

Although I know I can manually delete directories one by one, the script should have handled it elegantly.

curl -fsSLO https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
/bin/bash uninstall.sh --path /usr/local
Warning: This script will remove:
/etc/paths.d/homebrew
/Users/myusername/Library/Caches/Homebrew/
/Users/myusername/Library/Logs/Homebrew/
/usr/local/bin/brew -> /usr/local/bin/brew
/usr/local/Caskroom/
/usr/local/Cellar/
Are you sure you want to uninstall Homebrew? This will remove your installed packages! [y/N] y
==> Removing Homebrew installation...
Warning: Failed to delete /etc/paths.d/homebrew
rm: /etc/paths.d/homebrew: 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 {} ;
==> /usr/bin/sudo rmdir /usr/local
rmdir: /usr/local: Operation not permitted
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/bin/
/usr/local/com.cisco.packettracer/
/usr/local/etc/
/usr/local/Frameworks/
/usr/local/Homebrew/
/usr/local/include/
/usr/local/lib/
/usr/local/MacGPG2/
/usr/local/opt/
/usr/local/sbin/
/usr/local/share/
/usr/local/var/
You may wish to remove them yourself.

pyenv:8: command not found: pyenv                                                                                        
[myusername@ ~]% sudo !!
sudo curl -fsSLO https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh
/bin/bash uninstall.sh --path /usr/local
Password:
Failed to locate Homebrew!

What you expected to happen

Two options but the first one is preferred (second one for just-in-case)

  • It asks me for the password right when it needs it.
  • If the permission is not enough, stop the script so that it will not do the uninstall half way through.

Also consider but not necessarily:

  • Re-running should be possible.

Step-by-step reproduction instructions (by running brew commands)

  1. Make sure homebrew is installed in /usr/local
  2. curl -fsSLO https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh /bin/bash uninstall.sh --path /usr/local

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions