Skip to content

cask/uninstall: don't quit or signal the host process - #23695

Open
bevanjkay wants to merge 4 commits into
mainfrom
cask-skip-quit-host-terminal
Open

cask/uninstall: don't quit or signal the host process#23695
bevanjkay wants to merge 4 commits into
mainfrom
cask-skip-quit-host-terminal

Conversation

@bevanjkay

Copy link
Copy Markdown
Member
  • Prevent brew from quitting or signalling its host terminal.
  • Resolve host bundle IDs from the current process ancestry.
  • Cache ancestry lookups for each brew invocation.
  • Add test coverage for both quit and signal safeguards.

Resolves Homebrew/homebrew-cask#283947


  • Have you followed our Contributing guidelines?
  • Have you checked for other open Pull Requests for the same change?
  • Have you explained what your changes do? Performance claims (e.g. "this is faster") must include brew benchmark results.
  • Have you explained why you'd like these changes included, not just what they do?
  • For bug fixes, have you given step-by-step brew commands to reproduce the bug?
  • Have you written new tests (excluding integration tests)? Here's an example.
  • Have you successfully run brew lgtm (style, typechecking and tests) locally?

  • I did not use AI/LLM to create this PR, or I disclosed the tool/model below and reviewed its output; I did not attribute commits to AI and will answer maintainer questions and review comments myself without AI/LLM.

I used claude-code with Fable 5, reviewed and tested the changes myself, and with GPT-5.6-Sol.

Copilot AI balanced review requested due to automatic review settings August 29, 2026 02:00

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Prevents cask uninstall actions from terminating the application hosting the current brew process.

Changes:

  • Resolves host bundle IDs from cached process ancestry.
  • Skips matching quit and signal actions.
  • Adds safeguard tests and updates shared examples.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
Library/Homebrew/cask/artifact/abstract_uninstall.rb Adds host detection and safeguards.
Library/Homebrew/test/cask/artifact/uninstall_spec.rb Tests quit and signal protections.
Library/Homebrew/test/cask/artifact/shared_examples/uninstall_zap.rb Stubs ancestry lookup in shared tests.

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread Library/Homebrew/cask/artifact/abstract_uninstall.rb Outdated

@MikeMcQuaid MikeMcQuaid left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, good idea, let's just see if we can avoid osascript.

Comment on lines +365 to +383
ANCESTOR_BUNDLE_IDS_SCRIPT = <<~JAVASCRIPT
'use strict';

ObjC.import('AppKit')

function run(argv) {
var bundleIds = []

for (var i = 0; i < argv.length; i++) {
var app = $.NSRunningApplication.runningApplicationWithProcessIdentifier(parseInt(argv[i], 10))
if (!app.isNil() && !app.bundleIdentifier.isNil()) {
bundleIds.push(ObjC.unwrap(app.bundleIdentifier))
}
}

return bundleIds.join("\\n")
}
JAVASCRIPT
private_constant :ANCESTOR_BUNDLE_IDS_SCRIPT

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we try to use FFI or similar instead? This should also be doable without osascript I'd think. If the only way to do this is embedded JS: let's instead move the logic to a dedicated file for syntax highlighting etc.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.

Comment on lines +35 to +38
bundle_identifier = ObjectiveC.message_send(application, "bundleIdentifier", [], Fiddle::TYPE_VOIDP)
return if bundle_identifier.null?

ObjectiveC.message_send(bundle_identifier, "UTF8String", [], Fiddle::TYPE_VOIDP).to_s
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.

Ghostty cask started attempting to quit itself, and the updater process, on update.

3 participants