{"record":{"id":"4261e5e0b50403ba","repo":"Homebrew/homebrew-cask","slug":"unable-to-forcibly-close-teamviewer","errorCode":null,"errorMessage":"Unable to forcibly close TeamViewer","messagePattern":"Unable to forcibly close TeamViewer","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"Casks/t/teamviewer.rb","lineNumber":76,"sourceCode":"  desc \"Remote access and connectivity software focused on security\"\n  homepage \"https://www.teamviewer.com/\"\n\n  auto_updates true\n  conflicts_with cask: \"teamviewer-host\"\n  depends_on :macos\n\n  postflight_steps do\n    # postinstall launches the app\n    terminate_process(\n      \"/Applications/TeamViewer.app\",\n      match:           :full,\n      attempts:        3,\n      must_succeed:    false,\n      notices:         [\n        \"The TeamViewer package postinstall script launches the TeamViewer app\",\n        \"Attempting to close the TeamViewer app to avoid unwanted user intervention\",\n      ],\n      failure_message: \"Unable to forcibly close TeamViewer\",\n    )\n  end\n\n  uninstall launchctl: [\n              \"com.teamviewer.desktop\",\n              \"com.teamviewer.Helper\",\n              \"com.teamviewer.service\",\n              \"com.teamviewer.teamviewer\",\n              \"com.teamviewer.teamviewer_desktop\",\n              \"com.teamviewer.teamviewer_service\",\n              \"com.teamviewer.UninstallerHelper\",\n              \"com.teamviewer.UninstallerWatcher\",\n            ],\n            quit:      [\n              \"com.teamviewer.TeamViewer\",\n              \"com.teamviewer.TeamViewerUninstaller\",\n            ],\n            pkgutil:   [","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/Homebrew/homebrew-cask/blob/8587086220f4568daf43b90d1a0baf391e930c9e/Casks/t/teamviewer.rb#L58-L94","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"# before\nbrew upgrade --cask teamviewer\n# Warning: Unable to forcibly close TeamViewer\n\n# after: quit the app and stop the root service, then upgrade\nosascript -e 'quit app \"TeamViewer\"'\nsudo launchctl bootout system/com.teamviewer.service 2>/dev/null || true\nbrew upgrade --cask teamviewer","handlingStrategy":"validation","validationCode":"# Quit the app AND stop the root service that can relaunch it:\nosascript -e 'quit app \"TeamViewer\"' 2>/dev/null || true\nsudo launchctl bootout system/com.teamviewer.service 2>/dev/null || true\nbrew reinstall --cask teamviewer","typeGuard":null,"tryCatchPattern":"begin\n  Homebrew::SystemCommand.run!(\"/usr/bin/pkill\", args: [\"-f\", \"/Applications/TeamViewer.app\"])\nrescue ErrorDuringExecution\n  # Nothing matched, or a root-owned service respawned beyond reach.\n  warn \"Unable to forcibly close TeamViewer\"\nend","preventionTips":["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."],"tags":["homebrew","cask","macos","teamviewer","pkill","process-termination","postflight","launchd-service"],"backgroundTag":"pkill-no-process-matched","analyzedSha":"8587086220f4568daf43b90d1a0baf391e930c9e","analyzedAt":"2026-08-21T15:13:24.144Z","schemaVersion":2},"datasetVersion":"2026-08-21T18:17:14.833Z"}