Skip to content
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

Running straight from clone installation throws exception - Brew Casks Functionality Broken #196

Closed
BoggyBumblebee opened this issue Feb 21, 2024 · 4 comments
Labels

Comments

@BoggyBumblebee
Copy link

BoggyBumblebee commented Feb 21, 2024

Followed the steps provided, and I did not provide a custom config.yml, so using default 'default.config.yml'. When it comes to processing homebrew_cask_apps, it throws this error for every entry in the 'homebrew_cask_apps':

An exception occurred during task execution. To see the full traceback, use -vvv. The error was: TypeError: '<' not supported between instances of 'str' and 'int'
failed: [127.0.0.1] (item=chromedriver) => changed=false 
  ansible_loop_var: item
  item: chromedriver
  module_stderr: |-
    Traceback (most recent call last):
      File "/Users/cmb/.ansible/tmp/ansible-tmp-1708506861.4051142-1294-146175815614559/AnsiballZ_homebrew_cask.py", line 107, in <module>
        _ansiballz_main()
      File "/Users/cmb/.ansible/tmp/ansible-tmp-1708506861.4051142-1294-146175815614559/AnsiballZ_homebrew_cask.py", line 99, in _ansiballz_main
        invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
      File "/Users/cmb/.ansible/tmp/ansible-tmp-1708506861.4051142-1294-146175815614559/AnsiballZ_homebrew_cask.py", line 47, in invoke_module
        runpy.run_module(mod_name='ansible_collections.community.general.plugins.modules.homebrew_cask', init_globals=dict(_module_fqn='ansible_collections.community.general.plugins.modules.homebrew_cask', _modlib_path=modlib_path),
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 210, in run_module
        return _run_module_code(code, init_globals, run_name, mod_spec)
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 97, in _run_module_code
        _run_code(code, mod_globals, init_globals,
      File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.9/lib/python3.9/runpy.py", line 87, in _run_code
        exec(code, run_globals)
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 895, in <module>
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 887, in main
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 450, in run
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 523, in _run
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 671, in _install_casks
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 622, in _install_current_cask
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 485, in _current_cask_is_installed
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible_collections/community/general/plugins/modules/homebrew_cask.py", line 513, in _brew_cask_command_is_deprecated
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible/module_utils/compat/version.py", line 78, in __ge__
      File "/var/folders/vl/3dh1j32505z1s0dmgkk63z7m0000gn/T/ansible_homebrew_cask_payload_xmuhnua8/ansible_homebrew_cask_payload.zip/ansible/module_utils/compat/version.py", line 338, in _cmp
    TypeError: '<' not supported between instances of 'str' and 'int'
  module_stdout: ''
  msg: |-
    MODULE FAILURE
    See stdout/stderr for the exact error
  rc: 1

I can see where the error is (homebrew_cask.py), I'm struggling to find where that code resides, so I can work out what has gone wrong.

I know that the way in which Casks are installed has recently changed in homebrew, so I removed them and provided an empty 'homebrew_cask_apps' in the default config. The remainder of script then works. However, adding the cask list to the 'homebrew_installed_packages' did not work. Any suggestions on what needs to be fixed (happy to help), or a workaround?

@BoggyBumblebee BoggyBumblebee changed the title Running straight from clone installation throws exception Running straight from clone installation throws exception - Brew Casks Functionality Broken Feb 21, 2024
@BoggyBumblebee
Copy link
Author

Issue is found here in the homebrew. I see Jeff you commented on Ansible version being the issue - I'll see if that makes a difference. ansible-collections/community.general#1524

@BoggyBumblebee
Copy link
Author

BoggyBumblebee commented Feb 22, 2024

I've found the root of the issue. When homebrew is first installed in the VM that I am using to test the installation, running the command brew --version returns the string "Homebrew >=4.1.0 (shallow or no git repository)", which cannot be correctly parsed by the code in homebrew_cask.py in the function def _get_brew_version(self): on line 498, that in turn throws an issue on line 513:

return LooseVersion(self._get_brew_version()) >= LooseVersion('2.6.0')

If I run brew update and then brew --version it nows returns "Homebrew 4.2.9", and if the Ansible script is re-run, everything works.

In @geerlingguy's tasks/main.yml there is a step that should force an update, post installation of brew, when "not homebrew_binary.stat.exists", but that is being skipped, as I assume that does exist. Should it not be forced regardless? Clearly, I can run the Ansible script several times, but that feels wrong.

Copy link

This issue has been marked 'stale' due to lack of recent activity. If there is no further activity, the issue will be closed in another 30 days. Thank you for your contribution!

Please read this blog post to see the reasons why I mark issues as stale.

@github-actions github-actions bot added the stale label Jun 27, 2024
Copy link

This issue has been closed due to inactivity. If you feel this is in error, please reopen the issue or file a new issue with the relevant details.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant