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?

toro2k
19.3k8 gold badges66 silver badges72 bronze badges
asked Aug 1, 2013 at 22:42
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.

answered Aug 2, 2013 at 0:08

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!

Vlad Schnakovszki
8,6126 gold badges84 silver badges114 bronze badges
answered Mar 16, 2014 at 21:57

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.