Yelp/dumb-init

an ambigous error message when the interpreter not found

oprogramador opened this issue · 3 comments

/app # /usr/local/bin/dumb-init -- /app/watch.sh
[dumb-init] /app/watch.sh: No such file or directory
/app # /usr/local/bin/dumb-init /app/watch.sh
[dumb-init] /app/watch.sh: No such file or directory
/app #
/app # cat /app/watch.sh
#!/usr/local/bin/bash

while true
do
  time ./runner
  sleep 120
done
/app #

It works after replacing #!/usr/local/bin/bash to #!/bin/sh.

So IMO dumb-init should have an error message improved to something like that:

[dumb-init] /app/watch.sh: /usr/local/bin/bash: No such file or directory

The same error message is displayed when a file to run isn't found:

/app # /usr/local/bin/dumb-init foobarbaz
[dumb-init] foobarbaz: No such file or directory
/app # cat foobarbaz
cat: can't open 'foobarbaz': No such file or directory

this is the message that's handed from the OS, we have no control over it

compare with what python sees:

>>> subprocess.call(('./t',))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: './t'
>>> subprocess.call(('does-not-exist',))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.8/subprocess.py", line 340, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.8/subprocess.py", line 854, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "/usr/lib/python3.8/subprocess.py", line 1702, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'does-not-exist'

(./t is set up in the same way as your executable)