Where do I save my ruby (.rb) files? [duplicate]

2019-09-21 19:38发布

问题:

This question already has an answer here:

  • How do I save a ruby file? (error) 1 answer

I am receiving the error No such file or directory in my command line and I think it's because I am not saving the ruby files somewhere specific. All I did was create a random folder where I would save my ruby files.

Do I need to save my scripts in the original ruby folder? Thanks!

** This is Windows 7.

回答1:

No, you can save your .rb files anywhere you can write. If you want to access a script no matter what your current directory, put the script in a directory that is part of your shell's PATH.

Are you comfortable using the shell on your machine? If not, you should learn a little about how to navigate directories, how commands are found, and the like. It will pay dividends.



回答2:

On Windows, depending on how your editor is set up, you may have the extension of .txt appended to your file, and so when you go to run Matz.rb it doesn't really exist, it is really `Matz.rb.txt.

This may or may not be happening with you, but a way to check is to open your command prompt, and do a dir in the folder to see what files you have there.