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

/bin/sh: /usr/bin/env python3: No such file or directory #161

Open
xocoru opened this issue Sep 12, 2024 · 1 comment
Open

/bin/sh: /usr/bin/env python3: No such file or directory #161

xocoru opened this issue Sep 12, 2024 · 1 comment

Comments

@xocoru
Copy link

xocoru commented Sep 12, 2024

I have a problem with ansible 2.17.4 on MacOS. It says "/bin/sh: /usr/bin/env python3: No such file or directory\n"

(.venv) aivanov@localhost ansible-playground % ansible --version
ansible [core 2.17.4]
  config file = /Users/aivanov/Git/ansible-playground/ansible.cfg
  configured module search path = ['/Users/aivanov/Git/ansible-playground/nodules']
  ansible python module location = /Users/aivanov/Git/ansible-playground/.venv/lib/python3.12/site-packages/ansible
  ansible collection location = /Users/aivanov/Git/ansible-playground/collections
  executable location = /Users/aivanov/Git/ansible-playground/.venv/bin/ansible
  python version = 3.12.3 (v3.12.3:f6650f9ad7, Apr  9 2024, 08:18:47) [Clang 13.0.0 (clang-1300.0.29.30)] (/Users/aivanov/Git/ansible-playground/.venv/bin/python3.12)
  jinja version = 3.1.4
  libyaml = True
(.venv) aivanov@localhost ansible-playground % 

Error:

Using module file /Users/aivanov/Git/ansible-playground/collections/ansible_collections/brocade/fos/plugins/modules/brocade_facts.py
<localhost> PUT /Users/aivanov/.ansible/tmp/ansible-local-52850rq3grmi8/tmp2wfo4jmd TO /Users/aivanov/.ansible/tmp/ansible-tmp-1726148600.8854022-52872-265046520928014/AnsiballZ_brocade_facts.py
<localhost> EXEC /bin/sh -c 'chmod u+x /Users/aivanov/.ansible/tmp/ansible-tmp-1726148600.8854022-52872-265046520928014/ /Users/aivanov/.ansible/tmp/ansible-tmp-1726148600.8854022-52872-265046520928014/AnsiballZ_brocade_facts.py && sleep 0'
<localhost> EXEC /bin/sh -c ''"'"'/usr/bin/env python3'"'"' /Users/aivanov/.ansible/tmp/ansible-tmp-1726148600.8854022-52872-265046520928014/AnsiballZ_brocade_facts.py && sleep 0'
<localhost> EXEC /bin/sh -c 'rm -f -r /Users/aivanov/.ansible/tmp/ansible-tmp-1726148600.8854022-52872-265046520928014/ > /dev/null 2>&1 && sleep 0'
fatal: [nl-fc-24.mgmt.env -> localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "/bin/sh: /usr/bin/env python3: No such file or directory\n",
    "module_stdout": "",
    "msg": "The module failed to execute correctly, you probably need to set the interpreter.\nSee stdout/stderr for the exact error",
    "rc": 127
}

I think the problem is here with quoting:
EXEC /bin/sh -c ''"'"'/usr/bin/env python3'"'"' ...

Reproduce:

% /bin/sh -c '"'"'/usr/bin/env python3'"'"'         
/bin/sh: '/usr/bin/env python3': No such file or directory

Ansible seems to try to run "/usr/bin/env python3" as binary with space "env python3".

The solutions is just to remove "#!/usr/bin/env python3" in the first line of .py files

@prasad-valmeti-broadcom
Copy link
Collaborator

Thanks for the information.
FOS Ansible 1.3.4 supports Ansible version 2.7 only. In FOS Ansible 2.0.0, will support latest Ansible version.
We are replacing python3 with python, that also works with the latest Ansible version. Please let us know if you see any issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants