ansible-collection-mac
ansible-collection-mac copied to clipboard
Workaround to overcome the homebrew role failing because of PATH
Intro
It's still unclear to me, but this error seems to happen on ARM-based macOS
What you could get
When using the homebrew role in a playbook as follows
roles:
- elliotweiser.osx-command-line-tools
- geerlingguy.mac.homebrew
you could get errors like Failed to find required executable brew in paths
TASK [homebrew : Ensure configured taps are tapped.] ***************************
failed: [default] (item=homebrew/core) => {"ansible_loop_var": "item", "changed": false, "item": "homebrew/core", "msg": "Failed to find required executable brew in paths: /opt/homebrew/Homebrew:/usr/bin:/bin:/usr/sbin:/sbin"}
failed: [default] (item=homebrew/cask) => {"ansible_loop_var": "item", "changed": false, "item": "homebrew/cask", "msg": "Failed to find required executable brew in paths: /opt/homebrew/Homebrew:/usr/bin:/bin:/usr/sbin:/sbin"}
failed: [default] (item=adoptopenjdk/openjdk) => {"ansible_loop_var": "item", "changed": false, "item": "adoptopenjdk/openjdk", "msg": "Failed to find required executable brew in paths: /opt/homebrew/Homebrew:/usr/bin:/bin:/usr/sbin:/sbin"}
How to solve it
tasks:
- name: Install HomeBrew
include_role:
name: geerlingguy.mac.homebrew
apply:
environment:
PATH: '{{homebrew_install_path}}/bin:{{ ansible_env.PATH }}'
I came across the same error in issue #47 and i also did the same thing. After that i used an export command in the .zshrc to not longer have to deal with this in the playbooks.
Note that what I currently do is add this to my instructions:
https://github.com/geerlingguy/mac-dev-playbook#installation
Run the following command to add Python 3 to your $PATH:
export PATH="$HOME/Library/Python/3.8/bin:/opt/homebrew/bin:$PATH"
And in my dotfiles, I have this line: https://github.com/geerlingguy/dotfiles/blob/master/.zshrc#L22
I would prefer an automation step in stead of an instruction.
I agree with @dspolleke. This should be definitely automated and able to work out of the box.
Additionally, I had to add another env var (HOMEBREW_FORCE_BREWED_CURL
) to make it work with M1
tasks:
- name: Install HomeBrew
include_role:
name: geerlingguy.mac.homebrew
apply:
environment:
PATH: '{{homebrew_install_path}}/bin:{{ ansible_env.PATH }}'
HOMEBREW_FORCE_BREWED_CURL: 1
Something like that could work — I've traditionally just updated the path by hand, but if someone were willing to make a PR I would be willing to merge.
Would this be something we fix in the collection / role. but i do not see how i can include this in the tasks/main.yml file or where it should be implemented. We could fix it in the mac-dev-playbook. i would prefer to fix it here...
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.
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.