Running Ruby In Cloud9


#1

Hello all. I am new to programming. I have gone through Codecademy’s Ruby course (where the editor and terminal or console are basically on the same page as you write your code), and have now started trying to write code in Cloud9 with the text-editor and terminal (Bash) here. I am having trouble figuring out how to run my Ruby code in the terminal. I have created and saved a folder in the editor, but when I try to run “ruby calc.rb” (calc.rb being my filename), I am told this:

andycaree:~/workspace $ ruby calc.rb
ruby: No such file or directory – calc.rb (LoadError)

How can I see the output of the code I write? Do I need to get my Ruby folder into my my system path first? If so, how do I go about doing that? Being new, pleas give me a few passes on fouling up some of the terminology. Thanks.


#2

You are indeed using the correct command (ruby) to run Ruby files.

However your problem could be that you are not in the proper file location in your terminal.

Make sure to navigate first to the right directory where your file resides, or specify the correct path in the ruby command.


#3

Thanks man. I learned that I need to first mkdir a ruby directory! It’s all about learning right? Thanks again.