This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author izbyshev
Recipients hroncok, izbyshev, nanjekyejoannah, pablogsal, torsava, vstinner
Date 2021-02-03.13:51:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1612360278.38.0.705835171408.issue43113@roundup.psfhosted.org>
In-reply-to
Content
> Ideally, the error would say:

> FileNotFoundError: ./demo: /usr/bin/hugo: bad interpreter: No such file or directory

The kernel simply returns ENOENT on an attempt to execve() a file with non-existing hash-bang interpreter. The same occurs on an attempt to run a dynamically linked ELF executable with INTERP program header containing a non-existing path. And, of course, the same error is returned if the executable file itself doesn't exist, so there is no simple way to distinguish such cases.

Bash simply assumes[1] that if a file contains a hash-bang and the error from execve() is not recognized otherwise, it's a "bad interpreter".

Note that all of the above is completely unrelated to os.posix_spawn(): subprocess or os.execve() would produce the same message.

[1] https://git.savannah.gnu.org/cgit/bash.git/tree/execute_cmd.c?h=bash-5.1#n5854
History
Date User Action Args
2021-02-03 13:51:18izbyshevsetrecipients: + izbyshev, vstinner, torsava, hroncok, pablogsal, nanjekyejoannah
2021-02-03 13:51:18izbyshevsetmessageid: <1612360278.38.0.705835171408.issue43113@roundup.psfhosted.org>
2021-02-03 13:51:18izbyshevlinkissue43113 messages
2021-02-03 13:51:18izbyshevcreate