Homebrew/homebrew-cask · warning
Unable to forcibly close TeamViewer
Error message
Unable to forcibly close TeamViewer
What it means
Printed by the terminate_process step inside teamviewer's postflight_steps (Casks/t/teamviewer.rb:76). TeamViewer's .pkg postinstall launches the app, so Homebrew runs `/usr/bin/pkill -f /Applications/TeamViewer.app` up to 3 times, 1 second apart. pkill returns non-zero when no process's full command line matches that path or when signalling is not permitted; after the last failed attempt the failure_message is printed as a `Warning:` via opoo. With `must_succeed: false` the step is non-fatal — the warning only indicates the pattern never matched, not that the cask install failed.
Source
Thrown at Casks/t/teamviewer.rb:76
desc "Remote access and connectivity software focused on security"
homepage "https://www.teamviewer.com/"
auto_updates true
conflicts_with cask: "teamviewer-host"
depends_on :macos
postflight_steps do
# postinstall launches the app
terminate_process(
"/Applications/TeamViewer.app",
match: :full,
attempts: 3,
must_succeed: false,
notices: [
"The TeamViewer package postinstall script launches the TeamViewer app",
"Attempting to close the TeamViewer app to avoid unwanted user intervention",
],
failure_message: "Unable to forcibly close TeamViewer",
)
end
uninstall launchctl: [
"com.teamviewer.desktop",
"com.teamviewer.Helper",
"com.teamviewer.service",
"com.teamviewer.teamviewer",
"com.teamviewer.teamviewer_desktop",
"com.teamviewer.teamviewer_service",
"com.teamviewer.UninstallerHelper",
"com.teamviewer.UninstallerWatcher",
],
quit: [
"com.teamviewer.TeamViewer",
"com.teamviewer.TeamViewerUninstaller",
],
pkgutil: [View on GitHub (pinned to 8587086220)
Solutions
- If brew completed, treat the warning as advisory (`must_succeed: false`); quit any leftover app with `pkill -f /Applications/TeamViewer.app`.
- Quit TeamViewer from its menu-bar icon or `osascript -e 'quit app "TeamViewer"'` before the brew operation, then re-run.
- If TeamViewer keeps coming back, stop the respawning service first: `sudo launchctl bootout system/com.teamviewer.service` (also check com.teamviewer.teamviewer_service), then `brew reinstall --cask teamviewer`.
- Verify with `pgrep -fl TeamViewer` which instance (and path) is actually alive; if it differs from /Applications/TeamViewer.app, the cask path is stale — `brew edit --cask teamviewer` and open a PR.
- Disable 'Start TeamViewer with system' in TeamViewer preferences before upgrades to avoid respawn races.
Example fix
# before brew upgrade --cask teamviewer # Warning: Unable to forcibly close TeamViewer # after: quit the app and stop the root service, then upgrade osascript -e 'quit app "TeamViewer"' sudo launchctl bootout system/com.teamviewer.service 2>/dev/null || true brew upgrade --cask teamviewer
Defensive patterns
Strategy: validation
Validate before calling
# Quit the app AND stop the root service that can relaunch it: osascript -e 'quit app "TeamViewer"' 2>/dev/null || true sudo launchctl bootout system/com.teamviewer.service 2>/dev/null || true brew reinstall --cask teamviewer
Try / catch
begin
Homebrew::SystemCommand.run!("/usr/bin/pkill", args: ["-f", "/Applications/TeamViewer.app"])
rescue ErrorDuringExecution
# Nothing matched, or a root-owned service respawned beyond reach.
warn "Unable to forcibly close TeamViewer"
end Prevention
- Quit TeamViewer from its menu-bar icon before brew operations.
- Stop the respawning service first: `sudo launchctl bootout system/com.teamviewer.service`, then re-run brew.
- Uncheck 'Start TeamViewer with system' before upgrading to avoid respawn races during the retry window.
- Remember must_succeed: false makes the warning advisory; verify /Applications/TeamViewer.app state after install.
When it happens
Trigger: `brew install|upgrade|reinstall --cask teamviewer` where each pkill attempt finds nothing to signal: postinstall's launch never happened (headless Mac, no GUI login), the app appeared after the ~3s window, a running TeamViewer executes from a different path, or a root-owned/respawned instance (TeamViewer runs com.teamviewer.service and several launchd jobs listed in the uninstall stanza) could not be signalled by the user-level pkill.
Common situations: MacOS boxes where TeamViewer is configured as a system service ('start with system') so the app is spawned by a root daemon rather than the pkg postinstall; SSH/CI installs; user quits the app during the retry window; vendor renames TeamViewer.app in a pkg update.
Related errors
- Unable to forcibly close UU Remote
- Unable to forcibly close BEIDToken.app
- Unable to forcibly close BlurScreen.app
- Unable to forcibly close GameMaker LTS #{version.major}.app
- Unable to forcibly close GameMaker.app
AI-assisted analysis of Homebrew/homebrew-cask@8587086220 (2026-08-21).
Data as JSON: /api/errors/4261e5e0b50403ba.
Report an issue: GitHub.