Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

uninstall.sh: prevent deleting none related homebrew files #923

Closed
wants to merge 1 commit into from

Conversation

pheiduck
Copy link

@pheiduck pheiduck commented Dec 28, 2024

I uninstalled homebrew because of a problem.
Uninstaller prompted me to delete: /usr/local/MacGPG2/ which isn't a Homebrew related file so skip it to be shown on none deleted directories and files by the script.

@SMillerDev
Copy link
Member

I don't think we want to add special handling for tools that install in the homebrew prefix. Especially since it's the legacy prefix. But I'll leave this open for the opinions of others.

@pheiduck
Copy link
Author

Thanks, let me explain it a bit more the folder is from the GPG Suite
After the deletation from the directory the tool was broken.

@maxim-belkin
Copy link
Member

maxim-belkin commented Dec 28, 2024

I don't think we want to add special handling for tools...

I agree

... that install in the homebrew prefix.

Homebrew doesn't own /usr/local.

I uninstalled homebrew because of a problem.
Uninstaller prompted me to delete: /usr/local/MacGPG2/

@pheiduck: do you happen to have any logs? Without logs it's hard to tell what the issue is: why Homebrew prompted you to remove files in /usr/local instead of /opt/homebrew, what Homebrew version you had, ...?

I too have GPG Suite installed, but Homebrew uninstaller doesn't prompt me to remove it:

Screenshot

image

@pheiduck
Copy link
Author

pheiduck commented Dec 28, 2024

I don't think we want to add special handling for tools...

I agree

... that install in the homebrew prefix.

Homebrew doesn't own /usr/local.

I uninstalled homebrew because of a problem.
Uninstaller prompted me to delete: /usr/local/MacGPG2/

@pheiduck: do you happen to have any logs? Without logs it's hard to tell what the issue is: why Homebrew prompted you to remove files in /usr/local instead of /opt/homebrew, what Homebrew version you had, ...?

I too have GPG Suite installed, but Homebrew uninstaller doesn't prompt me to remove it:
Screenshot

$ uname -m                                                                                                                                           
x86_64
$ brew --version                                                                                                                                      
Homebrew 4.4.13-51-gaeed9ef
$ brew --prefix                                                                                                                                       
/usr/local
$ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/uninstall.sh)"
Warning: This script will remove:
/Users/pheiduck/Library/Caches/Homebrew/
/Users/pheiduck/Library/Logs/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]

@pheiduck
Copy link
Author

@maxim-belkin
Copy link
Member

Ok, so you've got x86_64 Mac and that's the reason your prefix is /usr/local. Can you find the flaw in script's logic that causes the uninstall.sh script to mark MacGPG2 files for deletion? As @SMillerDev pointed out - we shouldn't be calling out any specific tools in the script.

@pheiduck
Copy link
Author

It happen in this Part of the Script:

dir_children "${HOMEBREW_REPOSITORY}" "${HOMEBREW_PREFIX}" |
  sort -u >"${tmpdir}/residual_files"

if [[ -s "${tmpdir}/residual_files" && -z "${opt_quiet}" ]]
then
  echo "The following possible Homebrew files were not deleted:"
  while read -r f
  do
    pretty_print_pathnames "${f}"
  done <"${tmpdir}/residual_files"
  echo -e "You may wish to remove them yourself.\n"
fi

@pheiduck
Copy link
Author

add an one liner like: grep -v "MacGPG2" "${tmpdir}/residual_files" > "${tmpdir}/filtered_residual_files" could also help

@gromgit
Copy link
Member

gromgit commented Dec 29, 2024

add an one liner like: grep -v "MacGPG2" "${tmpdir}/residual_files" > "${tmpdir}/filtered_residual_files" could also help

Sorry, excluding just one of the potentially infinite number of possible directories that can be created by other software under /usr/local is the worst possible way to fix this.

@Homebrew/maintainers, thinking out loud: should uninstall.sh even look at /usr/local for residual files, since it's a known dumping ground for most open-source projects?

I uninstalled homebrew because of an problem.
Uninstaller prompted my to delete: /usr/local/MacGPG2/ which isn't a Homebrew related file so skip it to be shown on none deleted dirs and files by the script.
@carlocab
Copy link
Member

🤷 The current wording of

The following possible Homebrew files were not deleted:

and

You may wish to remove them yourself.

seems fine to me.

@pheiduck
Copy link
Author

okay, I close it now.

@pheiduck pheiduck closed this Dec 29, 2024
@pheiduck pheiduck deleted the patch-1 branch December 29, 2024 16:43
@maxim-belkin
Copy link
Member

@Homebrew/maintainers, thinking out loud: should uninstall.sh even look at /usr/local for residual files, since it's a known dumping ground for most open-source projects?

I don't think it should and if HOMEBREW_PREFIX == /usr/local, then don't clean up the folder.

gromgit added a commit to gromgit/homebrew-install that referenced this pull request Dec 30, 2024
It's a very common install prefix, so any residual files found here are likely false positives.

Followup to Homebrew#923.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants