Terminal not executing Ruby files

后端 未结 4 1955
佛祖请我去吃肉
佛祖请我去吃肉 2021-02-11 06:24

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 dir

相关标签:
4条回答
  • 2021-02-11 06:50

    ruby 1.9.3p0 (2011-10-30) [i386-mingw32]

    C:\Ruby Programs>ruby calc.rb

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

    C:\Ruby Programs>ruby calc.rb.txt

    3

    One should not have to add the .txt extension while attempting to run the program from whithin the program's home folder. I have to though.

    0 讨论(0)
  • 2021-02-11 06:50

    Did you call your file Calc.rb and saved it as a rb file to. becouse then its called internaly. Calc.rb.rb
    and be sure to run cmd from desktop :D

    0 讨论(0)
  • 2021-02-11 06:52

    In Terminal, did you change your current directory to your desktop before running your program ?

    If your program is stored on your desktop, you first need to change directory to your desktop or your Ruby script will not be found.

    $ cd Desktop
    $ ruby calc.rb
    
    0 讨论(0)
  • 2021-02-11 06:55

    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. type

    cd ~/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.

    0 讨论(0)
提交回复
热议问题