From: eregontp@... Date: 2020-06-11T19:51:59+00:00 Subject: [ruby-core:98746] [Ruby master Bug#16952] Kernel.exec gives an incorrect error message when passed a script with a non-existing shebang Issue #16952 has been updated by Eregon (Benoit Daloze). I would think this is just the errno you get from `execve(2)`. Ruby itself doesn't try to read the shebang. So not sure Ruby can do much here. `man execve` on Linux says: > ENOENT The file pathname or a script or ELF interpreter does not exist, or a shared library needed for the file or interpreter cannot be found. OTOH I think Bash has its own handling and actually reads the shebang (I'm not sure why, and it makes it all more confusing). ---------------------------------------- Bug #16952: Kernel.exec gives an incorrect error message when passed a script with a non-existing shebang https://bugs.ruby-lang.org/issues/16952#change-86104 * Author: deivid (David Rodr�guez) * Status: Open * Priority: Normal * ruby -v: ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-linux] * Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN ---------------------------------------- ``` $ cat myscript.rb #!/bad/ruby/shebang puts "Hei!" $ ruby -e 'Kernel.exec("myscript.rb")' Traceback (most recent call last): 1: from -e:1:in `
' -e:1:in `exec': No such file or directory - myscript.rb (Errno::ENOENT) ``` From the error, I understand that the script is not there, but the script is clearly there. I would've expected something more similar to what you get if you try to run the script directly from the shell: ``` $ ./myscript.rb bash: ./myscript.rb: /bad/ruby/shebang: bad interpreter: No such file or directory ``` -- https://bugs.ruby-lang.org/ Unsubscribe: