-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Homebrew module incorrectly fails executing task when package is already installed #864
Comments
Files identified in the description: If these files are inaccurate, please update the |
The issue seems to only happen with casks. e.g., the following works:
|
/assign |
It depends on the expected usage. For installing casks
However when using the
Seems like we should deal with the output message better but not sure if the |
@felixfontein Do you want the homebrew module to be more friendly with failing on cask issues; |
@MichaelWasher I don't use or maintain the module, so I'm not the right person to ask. In general, having better error messages is always a good thing though :) |
I think this would be preferred behaviour, seems unnecessary to have to split package installs between two separate modules when it could/should stay in
|
It all really depends on what everyone wants. But the issue for failing on already installed is due to the below lines, and could be resolved with the snippet below:
|
Actually looks like HomeBrew doesn't provode the same output depending on TTY and pipes... 👎 Something more like this would fix:
|
The latest updates to the homebrew & homebrew_cask modules that caught the regex issue for catching dashes is enough for me, it appears that was an underlying issues I hadn't noticed and it was forcing me to try to install some casks using homebrew which then wasn't idempotent. |
I ran into this problem as well and the issue is the following: At time X I ran brew info python3
python@3.8: stable 3.8.5 (bottled)
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@3.8/3.8.5 (4,372 files, 67.6MB) *
Poured from bottle on 2020-09-22 at 09:17:06
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python@3.8.rb
License: Python-2.0
[...] At time X+n I ran again
As you can see it says that the packge is not installed. If I use brew info python@3.8
python@3.8: stable 3.8.6 (bottled) [keg-only]
Interpreted, interactive, object-oriented programming language
https://www.python.org/
/usr/local/Cellar/python@3.8/3.8.5 (4,372 files, 67.6MB) *
Poured from bottle on 2020-09-22 at 09:17:06
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/python@3.8.rb
License: Python-2.0
[...] @MichaelWasher the fix you provided would not solve my issue in case I would use Of course one could argue whether I should actually use But still I thing this is an issue on brew side that it returns information about a package that it actually does not have locally. |
It would seem the homebrew_cask no longer works and is failing with the following error: Installing a cask with homebrew fails with the following: It looks like the module(s) require(s) updating to support Homebrew version 2.7.1 correctly. |
I'm having similar problem. My task ---
- name: install cask
when: ansible_distribution == 'MacOSX'
homebrew_cask:
name:
- docker
- firefox
- google-chrome
- password-gorilla
- slack
- spotify
- visual-studio
state: present Error I see:
Ansible version:
|
I would also expect using
|
@lockejan not sure how that is related to this bug report? Also we have no influence on what the package module does, that module is part of ansible-core. |
@felixfontein my bad. My initial thought was: why is it not possible to have one homebrew module for both variants (casks and non-casks)? |
I guess that would be great. I know too little about homebrew and casks to be able to say whether this is possible in a backwards-compatible way for the |
Facing the same issue. If an application is already installed without using homebrew, ansible install fails. Error: Specs: |
@prajain12 this issue is about apps installed by homebrew. If you install an app another way and try to install it with homebrew, that error is expected as far as I can tell. This is not a bug in the module, but expected behavior from homebrew. |
I am facing this issue as well. Since Homebrew removed the cask install option, I have added my cask install to the regular package mgmt module, which causes brew to fail if the package is already installed. Are there any updates to this, or is there a new issue tracking this problem? |
@jackfarzan You can add logic to check whether the app already exists at the destination or not. If it does not already exist, then you can move ahead with installing using homebrew. |
Hey folks, sorry for the delay. Could you please check if #4177 works for you and let me know? Thanks in advance. |
resolved_by_pr #4177 |
In order to maintain idempotency, detect already installed cask using ``brew ls`` command. Fixes: ansible-collections#864 Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
I applied the changes in https://github.com/ansible-collections/community.general/pull/4177/files (homebrew.py) and that fixes the issue with detecting already installed casks. +1 for not having to separate between |
I applied the last PR #4177 only the
I'm using the task as I don't know if I've to to a force reinstall with ansible first or what. |
I also ran into this issue with several package installations. The only package that works is zoxide because on |
Files identified in the description: If these files are incorrect, please update the |
@prajain12 i solved it with following work around
|
Hello, I've been using this module from the I tried to evaluate whether a package is installed with the command Could this be a valid solution? I'm considering to open a pull request to try to solve this. |
Sounds sensible to me, assuming that it isn't possible that (I have no idea how the |
Well thought, is unlikely but not impossible. I think that by using the JSON output of FormulaeCheck if installedbrew info --json=v2 <formula> | jq '.formulae[0].installed' Installed outputNot empty JSON array [
{
"version": "3.3a_3",
"used_options": [],
"built_as_bottle": true,
"poured_from_bottle": true,
"time": 1705034723,
"runtime_dependencies": [
...
]
}
] Not installed outputEmpty JSON array [] CasksCheck if installedbrew info --json=v2 <cask> | jq '.casks[0].installed' Installed outputNot empty JSON string "121.0.1" Not installed output
null Seems to me that if we check those fields of the JSON output and any of them are different from |
Using JSON output is generally the best way forward. Since when has JSON output been available for homebrew? The module doesn't seem to specify which versions of homebrew it supports, so this could be a bit tricky. |
Looks like at least a decade, according to blame on the docs. Brew v1 was released in 2016. Seems like a safe change to me. |
To clarify, according to docs, only the |
SUMMARY
results in
ISSUE TYPE
COMPONENT NAME
Homebrew module
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
Refer to summary.
EXPECTED RESULTS
I expect the task to complete successfully when a package is already installed and a
homebrew
task is executed with eitherstate: present
orstate: latest
.ACTUAL RESULTS
The task fails, as shown in the summary.
The text was updated successfully, but these errors were encountered: