How do i run my Ruby programs?

Started by
9 comments, last by rip-off 12 years ago
I know i have to use cmd to run my Ruby files but when i try nothing happens. The tutorials say to go into cmd and type "ruby my_program.rb" where "my_program.rb" is my file and ruby is supposed to do something. But when i do this nothing happens and i have my file named correctly. Do i need to have it in a certain place on my computer?
Advertisement
Do you have a ruby interpreter installed?
Not that i know of. I downloaded the ruby installer for 1.9.2 and thats all.
Are you on Windows?
yes i am
When you are trying to run the program from the cmd prompt do you first navigate to the proper directory containing the ruby file? Also make sure it installed properly by typing "ruby -v" on the command prompt.
It just keeps saying ruby is not recognized as an internal or external command.

EDIT: Although, when i use the start command prompt with ruby option it give me rubys info when i type ruby -v. Maybe i need to learn how to navigate to the correct directory so lets try that?
Haven't used the windows command line much (I use unix/linux) but after looking online a bit typing "cd" with no arguments will give you the directory you are currently working in the you will us cd to change directories.

"cd ../" is up one level from the current location, "cd name" changes to the directory named "name" within the current directory or you could do absolute path such as "cd c:\Users\K1NNY\Documents\Ruby" or wherever your stuff is stored. But you need to run the command in whatever form got ruby to be recognized as a command.

Once you are in the right folder try running the program again
this worked perfectly! thank you!
No problem. If you are interested here is a very basic introduction to some commonly used command line commands in Windows http://www.bleepingcomputer.com/tutorials/windows-command-prompt-introduction/

This topic is closed to new replies.

Advertisement