{"record":{"id":"0449341c822f7f20","repo":"Homebrew/homebrew-cask","slug":"unable-to-forcibly-close-beidtoken-app","errorCode":null,"errorMessage":"Unable to forcibly close BEIDToken.app","messagePattern":"Unable to forcibly close BEIDToken\\.app","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Casks/b/beid-token.rb","lineNumber":32,"sourceCode":"\n  depends_on :macos\n\n  pkg \"eID-Quickinstaller-signed.pkg\"\n\n  postflight_steps do\n    # Description: Ensure console variant of postinstall is non-interactive.\n    # This is because `open \"$APP_PATH\"&` is called from the postinstall\n    # script of the package and we don't want any user intervention there.\n    terminate_process(\n      \"/Applications/BEIDToken.app\",\n      match:           :full,\n      attempts:        3,\n      must_succeed:    false,\n      notices:         [\n        \"The BEIDToken package postinstall script launches the BEIDToken app\",\n        \"Attempting to close BEIDToken.app to avoid unwanted user intervention\",\n      ],\n      failure_message: \"Unable to forcibly close BEIDToken.app\",\n    )\n  end\n\n  uninstall quit:    [\n              \"be.eid.BEIDtoken.app\",\n              \"be.fedict.BEIDToken.BEIDTokenApp\",\n            ],\n            pkgutil: [\n              \"be.eid.BEIDtoken.app\",\n              \"be.eid.middleware\",\n              \"be.fedict.BEIDToken.BEIDTokenApp\",\n            ]\n  # No zap stanza required\nend\n","sourceCodeStart":14,"sourceCodeEnd":47,"githubUrl":"https://github.com/Homebrew/homebrew-cask/blob/8587086220f4568daf43b90d1a0baf391e930c9e/Casks/b/beid-token.rb#L14-L47","documentation":"Printed by the terminate_process step in beid-token's postflight_steps (Casks/b/beid-token.rb:32). The Belgian eID middleware .pkg runs `open \"$APP_PATH\"&` from its postinstall script, auto-launching BEIDToken.app; Homebrew then runs `/usr/bin/pkill -f /Applications/BEIDToken.app` up to `attempts: 3` times, one second apart, to keep the install non-interactive. pkill exits non-zero whenever no running process's full command line contains that path (or signalling is denied), and after the last failed attempt Homebrew prints this failure_message as a `Warning:` via opoo. Because the cask sets `must_succeed: false`, the step never aborts the install — it only reports that the pattern went unmatched.","triggerScenarios":"`brew install|upgrade|reinstall --cask beid-token` where every pkill attempt fails: the app never launched (postinstall `open` failed over SSH/CI with no GUI login, or the pkg no longer auto-opens), the app appeared later than the ~3x1s retry window, the running instance's command line does not literally contain /Applications/BEIDToken.app (e.g. an older copy running from ~/Applications), or pkill lacked permission to signal the process. After the third attempt the warning is emitted and the install continues.","commonSituations":"Headless or CI installs with no logged-in Aqua session; upgrading while a manually installed BEIDToken copy runs from a different path; a vendor pkg update that renames or moves the .app bundle leaving the cask path stale; unusually slow app launch losing the race against the 3-attempt pkill window.","solutions":["If the brew command completed, treat the warning as benign — `must_succeed: false` means install continued; just quit any leftover instance with `pkill -f /Applications/BEIDToken.app`.","Quit BEIDToken before the brew operation: `osascript -e 'quit app \"BEIDToken\"'` (or Activity Monitor), then re-run `brew reinstall --cask beid-token`.","Check the result instead of re-running blindly: `brew list --cask --versions beid-token`.","If an instance really is running, find its actual path with `pgrep -fl BEIDToken`; if it differs from the cask's literal path the cask is stale — `brew edit --cask beid-token`, fix the path, and open a PR.","Maintainers: raise `attempts:` if slow launches regularly lose the race."],"exampleFix":"# before\nbrew upgrade --cask beid-token\n# Warning: Unable to forcibly close BEIDToken.app\n\n# after: quit the token app first, then upgrade\nosascript -e 'quit app \"BEIDToken\"' || pkill -f '/Applications/BEIDToken.app'\nbrew upgrade --cask beid-token","handlingStrategy":"validation","validationCode":"# Before brew install/upgrade --cask beid-token, ensure no BEIDToken instance will\n# be half-launched or running from a foreign path:\nosascript -e 'quit app \"BEIDToken\"' 2>/dev/null || pkill -f '/Applications/BEIDToken.app' 2>/dev/null || true\nbrew reinstall --cask beid-token","typeGuard":null,"tryCatchPattern":"begin\n  Homebrew::SystemCommand.run!(\"/usr/bin/pkill\", args: [\"-f\", \"/Applications/BEIDToken.app\"])\nrescue ErrorDuringExecution\n  # pkill exits 1 when nothing matched: the app simply was not running.\n  # Same contract as must_succeed: false - warn and continue.\n  warn \"Unable to forcibly close BEIDToken.app\"\nend","preventionTips":["Quit BEIDToken (menu bar or Activity Monitor) before any brew install/upgrade of beid-token.","Read the Warning as non-fatal: with must_succeed: false brew only reports the unmatched pkill; check the app state afterwards.","When editing the cask, keep the terminate_process path byte-identical to the bundle the pkg installs; confirm with `ps ax -o command | grep -F BEIDToken.app` after a test install.","Run `brew update` first so the newest cask path and DSL semantics are in use."],"tags":["homebrew","cask","macos","beid-token","pkill","process-termination","postflight"],"backgroundTag":"pkill-no-process-matched","analyzedSha":"8587086220f4568daf43b90d1a0baf391e930c9e","analyzedAt":"2026-08-21T15:13:24.144Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}