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

Problems with the PATH fo mas commands #10

Closed
toby-griffiths opened this issue Jun 25, 2021 · 6 comments
Closed

Problems with the PATH fo mas commands #10

toby-griffiths opened this issue Jun 25, 2021 · 6 comments
Labels

Comments

@toby-griffiths
Copy link
Contributor

Hi there,

I'm running the mac-dev-setup playbook on a remote machine, and it's failing on the mas account task, as follows…

TASK [geerlingguy.mac.mas : Get MAS account status] **************************************************************************************
task path: /Users/toby/.ansible/collections/ansible_collections/geerlingguy/mac/roles/mas/tasks/main.yml:5
fatal: [marvin]: FAILED! => changed=false
  cmd: mas account
  failed_when_result: true
  msg: '[Errno 2] No such file or directory'
  rc: 2
  stderr: ''
  stderr_lines: <omitted>
  stdout: ''
  stdout_lines: <omitted>

I can run mas on the command line when logged in locally to the machine, without the full path, since /usr/local/bin is in my $PATH.

I've added a debug step to dump out the $PATH when using ansible and it seems to be missing /usr/local/bin for some reason…

TASK [geerlingguy.mac.mas : Debug mas cmd part 1] ****************************************************************************************
task path: /Users/toby/.ansible/collections/ansible_collections/geerlingguy/mac/roles/mas/tasks/main.yml:5
changed: [marvin] => changed=true
  cmd:
  - echo
  - $PATH
  delta: '0:00:00.002861'
  end: '2021-06-25 20:38:35.642596'
  rc: 0
  start: '2021-06-25 20:38:35.639735'
  stderr: ''
  stderr_lines: <omitted>
  stdout: /usr/bin:/bin:/usr/sbin:/sbin
  stdout_lines: <omitted>

What's the best way to fix this? I can submit a PR, but where should I be adding /usr/local/bin to the PATH? For all users (/etc/profile) or to just the current users, perhaps?

@toby-griffiths
Copy link
Contributor Author

I found this old post on your blog, however I don't have as /etc/profile.d/ directory. I think I'd need to add an include in the /etc/profile files to pick this up, right?

Sorry for all the questions. I just so I can get my PR done the right way.

@toby-griffiths
Copy link
Contributor Author

So I've checked my /etc/paths file, on the target machine, and that includes the path, so I'm not where ansible is picking up it's $PATH from, and I can't find any reference articles on how to update this path when connecting to a mac remotely using ansible.

@BadDoggie
Copy link

BadDoggie commented Jul 21, 2021

On my new BigSur, I find that mas is installed in /opt/homebrew/bin.

As a temporary workaround you can update the file roles/mas/defaults/main.yml, and add the path, so for example lines 5-6 look like this now:

- name: Get MAS account status
  command: /opt/homebrew/bin/mas account

This needs to be done for actions 2 through 6.

YMMV - Worked OK for me...

@toby-griffiths
Copy link
Contributor Author

@BadDoggie Thanks. Yeah I'd done that to get it working, but wondered what's the best way to resolve this for everyone.

@stale
Copy link

stale bot commented Oct 21, 2021

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.

@stale
Copy link

stale bot commented Nov 22, 2021

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.

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

2 participants