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

"#!/usr/bin/env python" doesn't work on Ubuntu 18.04 / python3 #5369

Closed
candlerb opened this issue Oct 11, 2019 · 3 comments
Closed

"#!/usr/bin/env python" doesn't work on Ubuntu 18.04 / python3 #5369

candlerb opened this issue Oct 11, 2019 · 3 comments
Labels
lifecycle/stale type/bug The PR fixed a bug or issue reported a bug

Comments

@candlerb
Copy link
Contributor

Describe the bug

Ubuntu 18.04 comes with python3 only by default, so scripts which try to start "python" don't work.

To Reproduce

On Ubuntu 18.04, try to start the sql worker:

$ bin/pulsar sql-worker run
/usr/bin/env: ‘python’: No such file or directory

Tracing shows that sql-worker runs lib/presto/bin/launcher which runs lib/presto/bin/launcher.py whose first line is #!/usr/bin/env python

The underlying problem is: Ubuntu 18.04 comes with python3 only by default. In the case of Ubuntu (and presumably Debian), "python" means python2, which is very shortly end-of-life.

Symlinking python3 to python is heavily discouraged, as it can badly break things which depend on python2.

It's not clear whether sql worker is compatible with python3 or not, but a workaround is to patch the files:

sed -i'' -e 's@^#!/usr/bin/env python$@#!/usr/bin/env python3@' $(grep -lR '^#!/usr/bin/env python$' .)

Expected behavior
sql worker should start

Desktop (please complete the following information):

  • OS: Ubuntu 18.04
@aahmed-se
Copy link
Contributor

This isn't a bug it's env specific issue. We can start discussing deprecating support for python2 but that's a different discussion.

@candlerb
Copy link
Contributor Author

Actually, I believe the shebang lines in these python source files are spurious, since they do not have the eXecute bit set anyway:

$ tar -tvzf apache-pulsar-2.4.1-bin.tar.gz | grep python_instance
-rw-r--r-- jia/staff     10165 2019-08-28 08:59 apache-pulsar-2.4.1/instances/python-instance/python_instance_main.py
-rw-r--r-- jia/staff      3384 2019-08-28 08:59 apache-pulsar-2.4.1/instances/python-instance/tests/test_python_instance.py
-rw-r--r-- jia/staff     20104 2019-08-28 08:59 apache-pulsar-2.4.1/instances/python-instance/python_instance.py

Shebangs are only needed if you exec() the file directly. So I'm guessing pulsar is explicitly running the interpreter, like /usr/bin/python <path-to-file>.py, but I can't find that code right now.

If it's true, then I think it would be good idea to remove all the shebang lines to avoid confusion.

@tisonkun
Copy link
Member

tisonkun commented Nov 9, 2022

The related script is updated as:

exec python3 ${TRINO_HOME}/bin/launcher.py --etc-dir ${PULSAR_TRINO_CONF} "${@}"

... so that I think this issue should be resolved.

@tisonkun tisonkun closed this as completed Nov 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

No branches or pull requests

5 participants