Buggy shebang behavior with different newline style

Hi,
After some puzzling I found out why my script with correct shebang line
(#!/usr/bin/env ruby) resulted in

: No such file or directory

when run as ./script.rb on my redhat linux system (it worked ok with “ruby
…/script.rb”). It turned out that the newlines in the script file where done
in dos style (0x0d, 0x0a) instead of common unix style (0x0a) and converting
the newlines solved the problem.

Paul

Dang, that’s in 1.6.7, BTW
Paul

“Paul E.C. Melis” paul@floorball.nl wrote in message
news:aom7rm$a1b$1@ares.cs.utwente.nl…

Hi,
After some puzzling I found out why my script with correct shebang line
(#!/usr/bin/env ruby) resulted in

: No such file or directory

when run as ./script.rb on my redhat linux system (it worked ok with “ruby
./script.rb”). It turned out that the newlines in the script file where
done
in dos style (0x0d, 0x0a) instead of common unix style (0x0a) and
converting

···

the newlines solved the problem.

Paul

Hi,

···

At Thu, 17 Oct 2002 20:46:52 +0900, Paul E.C. Melis paul@floorball.nl wrote:

After some puzzling I found out why my script with correct shebang line
(#!/usr/bin/env ruby) resulted in

: No such file or directory

when run as ./script.rb on my redhat linux system (it worked ok with “ruby
…/script.rb”). It turned out that the newlines in the script file where done
in dos style (0x0d, 0x0a) instead of common unix style (0x0a) and converting
the newlines solved the problem.

It’s due to the kernel behavior. Claim to the linux
developers.


Nobu Nakada

This is an operating system thing, nothing to do with Ruby; the error is
coming from it trying to execute the interpreter;

irb(main):001:0> system("/usr/bin/env ruby\r")
: No such file or directory

The \r is moving the cursor to the start of the line then the error is
overwriting the filename.

···
  • Paul E.C. Melis (paul@floorball.nl) wrote:

After some puzzling I found out why my script with correct shebang
line (#!/usr/bin/env ruby) resulted in

: No such file or directory

when run as ./script.rb on my redhat linux system (it worked ok with
“ruby …/script.rb”). It turned out that the newlines in the script
file where done in dos style (0x0d, 0x0a) instead of common unix style
(0x0a) and converting the newlines solved the problem.


Thomas ‘Freaky’ Hurst - freaky@aagh.net - http://www.aagh.net/

After all is said and done, a hell of a lot more is said than done.

Hi,

···

At Thu, 17 Oct 2002 20:46:52 +0900, Paul E.C. Melis paul@floorball.nl wrote:

After some puzzling I found out why my script with correct shebang line
(#!/usr/bin/env ruby) resulted in

: No such file or directory

when run as ./script.rb on my redhat linux system (it worked ok with “ruby
…/script.rb”). It turned out that the newlines in the script file where done
in dos style (0x0d, 0x0a) instead of common unix style (0x0a) and converting
the newlines solved the problem.

An easy workaround. :wink:

ln -s ruby “/usr/bin/ruby^M”


Nobu Nakada