[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Bad interpreter

Jordi Bunster

1/19/2005 6:03:00 AM

Hey folks. I'm pretty puzzled.

I installed Ruby 1.8.2 from backports onto Debian woody
(http://people.debian.org/...). If I type ruby -v I get: ruby
1.8.2 (2004-07-29) [i386-linux].

If I type which ruby I get: /usr/bin/ruby

The backported packages create ruby1.8, irb1.8, ri1.8 and so forth. I
created hard links to each of them without the 1.8 suffixes. There's no
ruby1.6 stuff installed.

If I try to run instiki by typing 'ruby instiki' it works just fine.
But if I ever try running it as ./instiki I get:

: bad interpreter: No such file or directory

What gives?

--
Jordi



8 Answers

Shajith

1/19/2005 7:44:00 AM

0

> If I try to run instiki by typing 'ruby instiki' it works just fine.
> But if I ever try running it as ./instiki I get:
>
> : bad interpreter: No such file or directory

I have the same problem with my ubuntu installation at home, googling
leads me to info about trailing ^M characters at the end of the
"shebang" line(the "#!/usr/bin/ruby" line at the top of the script).
Haven't checked this, though. Try removing any such control characters
at the end of the shebang line and see if it works.

> --
> Jordi

HTH
- CT


Alexey Verkhovsky

1/19/2005 10:43:00 AM

0

CT wrote:

>>: bad interpreter: No such file or directory
>>
>>
>I have the same problem with my ubuntu installation at home, googling
>leads me to info about trailing ^M characters at the end of the
>"shebang" line(the "#!/usr/bin/ruby" line at the top of the script).
>Haven't checked this, though. Try removing any such control characters
>at the end of the shebang line and see if it works.
>
>
Yup, that's what it is in case of Instiki 0.9.2. My fault.

To fix, do: "dos2unix ./instiki"

--
Best regards,

Alexey Verkhovsky

Ruby Forum: http://ruby... (moderator)
RForum: http://rforum.and... (co-author)
Instiki: http://i... (maintainer)



Florian Gross

1/19/2005 12:29:00 PM

0

CT wrote:

>>If I try to run instiki by typing 'ruby instiki' it works just fine.
>>But if I ever try running it as ./instiki I get:
>>
>>: bad interpreter: No such file or directory
>
> I have the same problem with my ubuntu installation at home, googling
> leads me to info about trailing ^M characters at the end of the
> "shebang" line(the "#!/usr/bin/ruby" line at the top of the script).
> Haven't checked this, though. Try removing any such control characters
> at the end of the shebang line and see if it works.

I think this issue will be fixed in the next Ruby release when you do
#!/usr/bin/ruby -w (Might also not occur in it when you have a space
after the "ruby", I'm not sure here, but "-w" is a good idea anyway.)

Chris Bennetts

1/20/2005 12:26:00 AM

0

Florian Gross wrote:

> I think this issue will be fixed in the next Ruby release when you do
> #!/usr/bin/ruby -w (Might also not occur in it when you have a space
> after the "ruby", I'm not sure here, but "-w" is a good idea anyway.)

It's not a Ruby problem at all. It's a kernel problem. The trailing ^M
on the #! line is causing the part of the kernel's exec() routines that
dispatches executable shell scripts to become confused.

The only solution (apart from propogating a kernel patch) is to remove
the trailing ^M (carriage return) from the #! line.

--Chris

Florian Gross

1/20/2005 12:26:00 AM

0

Chris Bennetts wrote:

>> I think this issue will be fixed in the next Ruby release when you do
>> #!/usr/bin/ruby -w (Might also not occur in it when you have a space
>> after the "ruby", I'm not sure here, but "-w" is a good idea anyway.)
>
> It's not a Ruby problem at all. It's a kernel problem. The trailing ^M
> on the #! line is causing the part of the kernel's exec() routines that
> dispatches executable shell scripts to become confused.
>
> The only solution (apart from propogating a kernel patch) is to remove
> the trailing ^M (carriage return) from the #! line.

I know what's happening. This can be handled by Ruby in most cases. (The
kernel just passes along the trailing \r to Ruby's ARGV.) That's why I
suggested adding the -w flag. (So that the Kernel would not try to run
the script with an executable called "ruby\r")

Chris Bennetts

1/20/2005 7:07:00 AM

0

Florian Gross wrote:

> I know what's happening. This can be handled by Ruby in most cases. (The
> kernel just passes along the trailing \r to Ruby's ARGV.) That's why I
> suggested adding the -w flag. (So that the Kernel would not try to run
> the script with an executable called "ruby\r")

That solves the "bad interpreter" problem nicely, but leaves ruby with a
"-w\r" argument to deal with. As you suggested earlier, if a future
version of Ruby handled stray carriage returns in its arguments, then
the problem would be resolved.

--Chris

Florian Gross

1/20/2005 1:13:00 PM

0

Chris Bennetts wrote:

>> I know what's happening. This can be handled by Ruby in most cases.
>> (The kernel just passes along the trailing \r to Ruby's ARGV.) That's
>> why I suggested adding the -w flag. (So that the Kernel would not try
>> to run the script with an executable called "ruby\r")
>
> That solves the "bad interpreter" problem nicely, but leaves ruby with a
> "-w\r" argument to deal with. As you suggested earlier, if a future
> version of Ruby handled stray carriage returns in its arguments, then
> the problem would be resolved.

Nobu has done a patch for exactly that when I requested this on
ruby-core. So all this is indeed going to be quite a bit less
problematic in the future. (I was bitten by this behavior by myself and
while it's not Ruby's fault it can still try to help.)

Jordi Bunster

1/20/2005 6:02:00 PM

0


On Jan 19, 2005, at 2:44 AM, CT wrote:

>> If I try to run instiki by typing 'ruby instiki' it works just fine.
>> But if I ever try running it as ./instiki I get:
>>
>> : bad interpreter: No such file or directory
>
> I have the same problem with my ubuntu installation at home, googling
> leads me to info about trailing ^M characters at the end of the
> "shebang" line(the "#!/usr/bin/ruby" line at the top of the script).
> Haven't checked this, though. Try removing any such control characters
> at the end of the shebang line and see if it works.

Thanks everyone. I had not touched on the problem until right now, thus
the silence.

But you were all right. tr -d '\15\32' on the 'instiki' file and it all
worked great.

Once again, thanks a bunch.

--
Jordi