终端不执行Ruby文件 [英] Terminal not executing Ruby files
问题描述
我对编程几乎是全新的,所以忍受我。我在Macbook Pro上运行10.6.6。
在学习计划教程是这些方向:
保存程序(是的,这是一个程序!)as calc.rb rb是我们通常放在Ruby写的程序的结尾。现在通过在你的命令行中输入ruby calc.rb来运行你的程序。它应该在你的屏幕上放3。
当我输入 ruby calc.rb
我得到以下错误:
ruby:没有这样的文件或目录 - calc.rb )
我做错了什么?
如果您已命名文件Calc.rb,则Calc.rb 你需要运行 ruby Calc.rb
(资本C)。
此外,请确保您导航的是 / Desktop
目录。类型
cd〜/ Desktop
pre>
ruby Calc.rb
您可以使用
ls
获取当前目录中的所有文件的列表。您可以使用它来查看您尝试执行的文件是否真的存在。I'm pretty much entirely new to programming, so bear with me. I am on a Macbook Pro running 10.6.6.
At the beginning of the "Learn to Program" tutorial are these directions:
Save your program (yes, that's a program!) as calc.rb (the .rb is what we usually put at the end of programs written in Ruby). Now run your program by typing ruby calc.rb into your command line. It should have put a 3 on your screen. See, programming isn't so hard, now is it?
When I type
ruby calc.rb
I get the following error:ruby: No such file or directory -- calc.rb (LoadError)
What am I doing wrong? "Calc.rb" is saved on my desktop, if it matters.
解决方案If you have named your file "Calc.rb" you'll need to run
ruby Calc.rb
(capital "C").Also make sure that you're navigating the
/Desktop
directory — e.g. typecd ~/Desktop ruby Calc.rb
You can use
ls
to get a list of all the files in the current directory. You could use that to see if the file you're trying to execute actually exists.这篇关于终端不执行Ruby文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!