hq: Invalid filename in shebang line
When I run hq, I always get an error. This error varies slightly, depending on the version of coreutils (which contains the env executable).
Ubuntu 18.04.3 (LTS) (coreutils v8.28):
~ $ hq
/usr/bin/env: ‘node --experimental-modules --no-warnings’: No such file or directory
Ubuntu 19.04 (coreutils v8.30):
~ $ hq
/usr/bin/env: 'node --experimental-modules --no-warnings': No such file or directory
/usr/bin/env: use -[v]S to pass options in shebang lines
I’m using hq version 0.0.12.
This seems to be caused by the shebang in this file: https://github.com/hqjs/hq/blob/1cd20a0a688c7468e357cacc0ef9ea3089746963/index.mjs#L1
From what I found out so far, a shebang can only contain a single parameter. In this case, the string node --experimental-modules --no-warnings is passed as a whole to /usr/bin/env, and since this is not an existing file, it cannot be executed.
A possible solution (as suggested in the second error message) is to use the -S flag, which splits up the argument at the whitespaces. That would look like this:
#!/usr/bin/env -S node --experimental-modules --no-warnings
(Unfortunately, this flag was only introduced in version 8.30 of coreutils, and as such is not present in older Ubuntu versions. However - if I understand correctly - the current version of the script doesn’t work on those versions anyway, so there is nothing to lose there.)
Can you confirm if this script works on other Linux versions or on Mac?
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (12 by maintainers)
Feels like bash script above is less attractive option. I will rather go with your fix. It will be available in 0.0.13 that will be released after
.tsxsupport being added. Thanks for PR once again.