Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"ruby filename.rb" is not opening my file

I'm new to Ruby, new to scripting languages, but not entirely new to programming. I have about a year's experience with Java, but this whole command line thing is just messing with my head.

I'm following this tutorial, just for the heck of it:

http://www.ruby-lang.org/en/documentation/quickstart/3/

and it's all simple and fine until I'm asked to save a file and run it from the IRB. I enter "ruby ri20min.rb" (without quotations, of course) into the IRB. I get this error:

NameError: undefined local variable or method 'ri20min' for main:Object from (irb):1

What am I doing wrong? The tutorial seems to imply that the file is supposed to be run through IRB; but maybe it's supposed to got through Command Prompt? Well, I tried that too but it tells me:

'ruby' is not recognized as an internal or external command, operable program, or batch file.

Thanks in advance for any help you can give! This twenty minute tutorial has frustrated me for over an hour of syntax adjustments and googling.

like image 604
Alex Avatar asked Nov 05 '22 18:11

Alex


1 Answers

First, don't run ruby ri20min.irb from within IRB, you're supposed to run it from the command line, as you suspected. The error you get there is most likely related to the fact that the Ruby executable is not in your PATH environment variable.

like image 105
emboss Avatar answered Nov 15 '22 00:11

emboss