From 6458abb9c1a9f5b33230447ddfbe00e0812ec1fc Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 19 Apr 2026 12:49:23 +0200 Subject: [PATCH] [PR #11838/d0d213a4 backport][stable-12] homebrew_cask: fix false failure on upgrade of latest-versioned casks (#11880) homebrew_cask: fix false failure on upgrade of latest-versioned casks (#11838) * homebrew_cask: fix false failure on upgrade of latest-versioned casks Use rc == 0 to determine upgrade success, consistent with _upgrade_all(). The previous check (_current_cask_is_installed() and not _current_cask_is_outdated()) was unreliable: for `latest`-versioned casks under --greedy, brew may still list the cask as outdated after a successful upgrade, causing the task to fail with a harmless warning from stderr as the error message. Fixes #1647 * homebrew_cask: add changelog fragment for #11838 * Fix changelog fragment --------- (cherry picked from commit d0d213a41d99c760309008f65e3aa100e6e54c8c) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.6 --- changelogs/fragments/11838-homebrew-cask-upgrade-latest.yml | 6 ++++++ plugins/modules/homebrew_cask.py | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/11838-homebrew-cask-upgrade-latest.yml diff --git a/changelogs/fragments/11838-homebrew-cask-upgrade-latest.yml b/changelogs/fragments/11838-homebrew-cask-upgrade-latest.yml new file mode 100644 index 0000000000..ecaa3af02c --- /dev/null +++ b/changelogs/fragments/11838-homebrew-cask-upgrade-latest.yml @@ -0,0 +1,6 @@ +bugfixes: + - homebrew_cask - fix false task failure when upgrading casks with ``version=latest``; + the post-upgrade check incorrectly re-ran ``brew outdated`` (which always lists ``latest`` + casks as outdated under ``--greedy``), now uses the command exit code instead + (https://github.com/ansible-collections/community.general/issues/1647, + https://github.com/ansible-collections/community.general/pull/11838). diff --git a/plugins/modules/homebrew_cask.py b/plugins/modules/homebrew_cask.py index 316f3aef85..9677bc65fc 100644 --- a/plugins/modules/homebrew_cask.py +++ b/plugins/modules/homebrew_cask.py @@ -656,7 +656,7 @@ class HomebrewCask: else: rc, out, err = self.module.run_command(cmd) - if self._current_cask_is_installed() and not self._current_cask_is_outdated(): + if rc == 0: self.changed_count += 1 self.changed = True self.message = f"Cask upgraded: {self.current_cask}"