brew
brew copied to clipboard
Cask `zap` script/early script to run at uninstall time
Verification
- [X] This issue's title and/or description do not reference a single formula e.g.
brew install wget. If they do, open an issue at https://github.com/Homebrew/homebrew-core/issues/new/choose instead.
Provide a detailed description of the proposed feature
At present, when --zap is passed to brew uninstall --cask that zap stanzas are fired together after the uninstall stanzas are completed.
This generally works okay, as the --zap will cleanup any leftover files. However, there are times where it is useful for a zap stanza to reference an uninstall script that is located inside of the application's .app. The issue here is that the .app is generally removed during the uninstall step, so it no longer exists when the zap is fired, and therefore the uninstall will error out.
Perhaps if a zap stanza has an early_script / script it should be merged with the uninstall scripts and run at the same time. Or we could have an additional artifact for zap that runs at uninstall time.
What is the motivation for the feature?
A couple of casks that would utilise this feature are orbstack, fig and private-internet-access.
https://github.com/Homebrew/homebrew-cask/pull/143807#discussion_r1149777915
How will the feature be relevant to at least 90% of Homebrew users?
What alternatives to the feature have been considered?
Not using a script in the zap stanza that references a file inside of the applications .app.
Makes sense to me!
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.
@bevanjkay, I think this is a great idea. I wonder what other people think about this, but given the overlapping functionality between uninstall and zap, would it not make sense to consolidate the operations? We could determine the arguments passed to each uninstall methods based on the presence of --zap. This might make more sense below.
e.g. for the following set of stanzas:
uninstall pkgutil: "com.google.pkg.GoogleJapaneseInput",
launchctl: [
"com.google.inputmethod.Japanese.Converter",
"com.google.inputmethod.Japanese.Renderer",
]
zap pkgutil: "com.google.pkg.Keystone",
launchctl: [
"com.google.keystone.agent",
"com.google.keystone.daemon",
"com.google.keystone.xpcservice",
],
trash: [
"~/Library/Application Support/Google/JapaneseInput",
"~/Library/Logs/GoogleJapaneseInput",
"~/Library/Saved Application State/com.google.inputmethod.Japanese.Tool.ConfigDialog.savedState",
]
rather than running uninstall followed by zap, when --zap is specified we would run:
uninstall pkgutil: [
"com.google.pkg.GoogleJapaneseInput",
"com.google.pkg.Keystone",
],
launchctl: [
"com.google.inputmethod.Japanese.Converter",
"com.google.inputmethod.Japanese.Renderer",
"com.google.keystone.agent",
"com.google.keystone.daemon",
"com.google.keystone.xpcservice",
],
trash: [
"~/Library/Application Support/Google/JapaneseInput",
"~/Library/Logs/GoogleJapaneseInput",
"~/Library/Saved Application State/com.google.inputmethod.Japanese.Tool.ConfigDialog.savedState",
]
otherwise we would run:
uninstall pkgutil: "com.google.pkg.GoogleJapaneseInput",
launchctl: [
"com.google.inputmethod.Japanese.Converter",
"com.google.inputmethod.Japanese.Renderer",
]
This wouldn't need any changes in cask syntax, just in the way we handle uninstall and zap.
I think it would solve the issue raised here, and hopefully make https://github.com/Homebrew/brew/pull/15499 easier to implement.
@razvanazamfirei I think that is a sensible idea, I can't think of any side-effects right now, but there could be the potential that some things could be removed in the wrong order as a result of this change.
heya folks, i see that orbstack have some timer build-in to check is that actuall build, and this prevents proper deletion
brew uninstall orbstack
==> Uninstalling Cask orbstack
==> Running uninstall script /Applications/OrbStack.app/Contents/MacOS/bin/orbctl
panic: build expired
goroutine 1 [running]:
main.main()
github.com/kdrag0n/macvirt/scon/cmd/scli/main.go:19 +0x1b4
Error: Failure while executing; `/usr/bin/env /Applications/OrbStack.app/Contents/MacOS/bin/orbctl _internal brew-uninstall` exited with 2. Here's the output:
panic: build expired
goroutine 1 [running]:
main.main()
github.com/kdrag0n/macvirt/scon/cmd/scli/main.go:19 +0x1b4
and only way to fix it, is to download new pkg and replace old "installation"
There's been no movement in a year so: passing on this for now.