-
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_cask: unhelpful error when become_user set wrong #4708
Comments
Files identified in the description: If these files are incorrect, please update the |
@mitchblank Thanks for reporting this issue and doing an in-depth analysis. Would you be interested in opening a PR with your findings? Thanks. |
Might be a duplicate of #4734. |
I don't know if I'm the best placed to fix it. I'm fairly handy with python, but I would need to learn a lot about ansible internals. In particular, it's not clear to me at all what the best way of bubbling up the error would be. The current code does...
... so it seems that it's trying to catch the error via I suspect there could be a simple one-liner fix for that, but somebody with more ansible knowledge would have to be the one to determine what that is. |
I don't think this is related to the exit code. Also the command executed by the module for the version shouldn't have returned an exit code != 0, otherwise Ansible would have already exited. If it returned that exit code for you, you probably executed it in a slightly different environment where it did return that exit code. The bug that needs to be fixed is parsing the version from the version = out.split('\n')[0].split(' ')[1]
+ if version.startswith('>='):
+ version = version[2:]
self.brew_version = version |
Hmm, you seem to be right about the exit code. I could have sworn when I was debugging this earlier I found that
No, that won't be good enough. The reason that we're checking the version is for Basically the story seems to be that homebrew switched from a separate It might make sense to have |
Ok, that sucks quite a lot. I was hoping that they'd update that hardcoded version string regularly, so that (This is something that should be improved on homebrew's side.)
For checking Another approach would be to assume that Or only use this new test (check |
Files identified in the description: If these files are incorrect, please update the |
Is there a workaround? This completely prevents me from using Homebrew Casks on MacOS. |
Summary
I was trying to migrate management of homebrew casks to ansible, but I got this very confusing error from inside the
_brew_cask_command_is_deprecated()
function (added by @jaanhio as part of #1481)Well that's weird! I spent way too long staring at the code, but I couldn't figure out what had gone wrong.
As mentioned in the title, it was ultimately a configuration error which was causing the step to be executed as the wrong user. This meant that when
brew --version
was run it produced stdout......and stderr...
...and exited with status
1
. I guess because of the context that it's being called from, thecheck_rc=True
in_get_brew_version()
didn't have much effect. This is a shame, since if I had been given an error containing that stderr output I would have diagnosed the problem much quicker.Anyway, instead of failing it parsed the stdout as it found it and set
self.brew_version
to>=2.5.0
This then ended up being put into the (fairly fragile)LooseVersion
type which then failed awkwardly.As I said, the underlying issue was a misconfiguration on my part. However I wanted to open an issue for two reasons:
My suggestion:
_get_brew_version()
should sanity check the version string (at least make sure it starts with a digit) If it didn't return a sensible result, fail immediately and include the stderr frombrew --version
in the thrown exception.Issue Type
Bug Report
Component Name
homebrew_cask
Ansible Version
Community.general Version
Configuration
$ ansible-config dump --only-changed
OS / Environment
OS/X 12.4
Steps to Reproduce
Expected Results
An comprehensible error message
Actual Results
Code of Conduct
The text was updated successfully, but these errors were encountered: