0

I just installed Ruby 2.0.0-p247 on Windows 7 and I wrote a program called calc.rb which contains only one expression: puts 1 + 2. In my tutorial book it says to run it in the command line by typing ruby calc.rb, but when I try to run it it comes back with this message:

ruby: No such file or directory -- calc.rb (LoadError)

Why?

4
  • 1
    How did you install ruby? Seems like your console doesn't know about your installed ruby. Commented Aug 1, 2013 at 23:02
  • The ruby binary has to be in your PATH Commented Aug 1, 2013 at 23:26
  • 3
    @tessi, if the Ruby binary wasn't in the PATH, then Ruby wouldn't execute. In this case, Ruby is executing and reporting that it cannot find the file calc.rb Commented Aug 1, 2013 at 23:33
  • Are you sure that calc.rb is in the "current directory". Can you do a dir calc.rb or whatever the Windows/DOS command line command line is for listing a file? Commented Aug 1, 2013 at 23:35

2 Answers 2

1

You should be in the same folder that your script file to provide only the filename. If you don't, you should provide the relative or absolute path to your script file.

Sign up to request clarification or add additional context in comments.

Comments

0

I was getting the same error code in Windows 8. I had to get into the folder on my desktop via the command prompt (cd desktop\"folder name") and then type ruby calc.rb.txt for it to show 3 as the result. Hope this helps!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.