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?
2 Answers 2
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.
Comments
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!
ruby
binary has to be in yourPATH
PATH
, then Ruby wouldn't execute. In this case, Ruby is executing and reporting that it cannot find the filecalc.rb
dir calc.rb
or whatever the Windows/DOS command line command line is for listing a file?