Error while executing the code

i run the below code with ruby interpritor(1.8.7)

i am getting error " ruby: illegal switch in RUBYOPT: - (RuntimeError)"


class Animal
def set_noise(noi)
@noise=noi
end

def make_noise
@noise
end
end

ani=Animal.new
ani1=Animal.new
puts ani1.make_noise
ani.set_noise(“gur”)
puts ani.make_noise


if the same code is run in Netbeans IDE(Jruby) i am getting expected
output.

Can somebody explain the reason?

On Tuesday 12 October 2010, Ravikiran Basa wrote:

|

if the same code is run in Netbeans IDE(Jruby) i am getting expected
output.
Can somebody explain the reason?

The error you’re seeing doesn’t depend on your code, but it’s caused by
the
environment variable RUBYOPT including an invalid option. In case you
don’t
already know it, RUBYOPT is a list of options passed to ruby every time
it is
run and it’s used to avoid repeating the same options every time on the
command line. In your case, it seems that your RUBYOPTION contains an
invalid
option. For example, I get the same error message with the following
line:

RUBYOPT="-q" ruby
ruby: invalid option -q (-h will show valid options) (RuntimeError)

Try display the contents of RUBYOPT and see if it contains something
wrong.

I hope this helps

Stefano

Thanks Stefano,

I have run the above code (copied above code to test.rb) with the
command

RUBYOPT="-w" ruby /home/basa/Desktop/test.rb

then it worked fine.But can you tell me how to set RUBYOPT properly.

I mean i should be able to execute

ruby test.rb

ok i did
#unset RUBYOPT
Now it works fine.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs