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 · 4 comments
Open

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

xocoru opened this issue Sep 12, 2024 · 4 comments

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.

@prasad-valmeti-broadcom
Copy link
Collaborator

It is supported with Ansible 2.0 and will be available with that release.

@andy-maier
Copy link

andy-maier commented Jan 7, 2025

@prasad-valmeti-broadcom We are currently using our own Ansible modules for the Brocade SAN switches. These modules work against the CLI. We would very much like to move to the brocade.fos Ansible collection and sunset our own modules, but using Ansible 2.7 is not an option for us.

So we depend on this change and would like to get it as soon as possible.

Would it be possible to change just the shebang header in your Ansible modules and release a brocade.fos version 1.4.0 with that, so that we don't have to wait for the 2.0 version? We tested locally that changing just the shebang header is sufficient to make it work with the latest ansible-core version. We were testing with the zone and alias modules.

from:

#!/usr/bin/env python3

to:

#!/usr/bin/python

@sc2317
Copy link

sc2317 commented Jan 9, 2025

We are also facing same issue, can we fix this as quickly as possible. We can upgrade our collection to 1.3.4, however due to this issue, it will not help either as "py" files have '/usr/bin/env python3'

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

4 participants