Homebrew/homebrew-cask · warning

Unable to forcibly close BEIDToken.app

Error message

Unable to forcibly close BEIDToken.app

What it means

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.

Source

Thrown at Casks/b/beid-token.rb:32

  depends_on :macos

  pkg "eID-Quickinstaller-signed.pkg"

  postflight_steps do
    # Description: Ensure console variant of postinstall is non-interactive.
    # This is because `open "$APP_PATH"&` is called from the postinstall
    # script of the package and we don't want any user intervention there.
    terminate_process(
      "/Applications/BEIDToken.app",
      match:           :full,
      attempts:        3,
      must_succeed:    false,
      notices:         [
        "The BEIDToken package postinstall script launches the BEIDToken app",
        "Attempting to close BEIDToken.app to avoid unwanted user intervention",
      ],
      failure_message: "Unable to forcibly close BEIDToken.app",
    )
  end

  uninstall quit:    [
              "be.eid.BEIDtoken.app",
              "be.fedict.BEIDToken.BEIDTokenApp",
            ],
            pkgutil: [
              "be.eid.BEIDtoken.app",
              "be.eid.middleware",
              "be.fedict.BEIDToken.BEIDTokenApp",
            ]
  # No zap stanza required
end

View on GitHub (pinned to 8587086220)

Solutions

  1. 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`.
  2. Quit BEIDToken before the brew operation: `osascript -e 'quit app "BEIDToken"'` (or Activity Monitor), then re-run `brew reinstall --cask beid-token`.
  3. Check the result instead of re-running blindly: `brew list --cask --versions beid-token`.
  4. 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.
  5. Maintainers: raise `attempts:` if slow launches regularly lose the race.

Example fix

# before
brew upgrade --cask beid-token
# Warning: Unable to forcibly close BEIDToken.app

# after: quit the token app first, then upgrade
osascript -e 'quit app "BEIDToken"' || pkill -f '/Applications/BEIDToken.app'
brew upgrade --cask beid-token
Defensive patterns

Strategy: validation

Validate before calling

# Before brew install/upgrade --cask beid-token, ensure no BEIDToken instance will
# be half-launched or running from a foreign path:
osascript -e 'quit app "BEIDToken"' 2>/dev/null || pkill -f '/Applications/BEIDToken.app' 2>/dev/null || true
brew reinstall --cask beid-token

Try / catch

begin
  Homebrew::SystemCommand.run!("/usr/bin/pkill", args: ["-f", "/Applications/BEIDToken.app"])
rescue ErrorDuringExecution
  # pkill exits 1 when nothing matched: the app simply was not running.
  # Same contract as must_succeed: false - warn and continue.
  warn "Unable to forcibly close BEIDToken.app"
end

Prevention

When it happens

Trigger: `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.

Common situations: 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.

Related errors


AI-assisted analysis of Homebrew/homebrew-cask@8587086220 (2026-08-21). Data as JSON: /api/errors/0449341c822f7f20. Report an issue: GitHub.