31 Oct 2009, 13:58
Generic-user-small

Michael (1 post)

I am a brand new wanna be programmer and I am stuck on page 9 of “Learning To Program, 2nd Edition”. I cannot seem to get the program, calc.rb to run. The message I receive on the command prompt reads, “ruby: no such file or directory–calc.rb (LoadError).

I’m sorry this is such an elementary problem but I really want to learn how to program and being stuck on the example is humbling. Thanks, Michael

02 Nov 2009, 14:45
Med__2008.08.19.09.44.43_pragsmall

Chris Pine (58 posts)

You aren’t running from the correct directory. Look more closely at the first chapter, where it talks about navigating on the command-line.

14 Feb 2012, 01:07
Generic-user-small

Eddie Robbins (2 posts)

I have put the save file in Program files, I have Ruby installed in program files, I am running windows 7 and all I keep getting is no such file or direcory – calc.rb load error

03 Mar 2012, 20:12
Generic-user-small

Naughty Ninja (3 posts)

I had the issue at first but then i changed directories, but my issue is when i rename it to “calc.rb” it becomes “calc.rb.txt” so i cant just “ruby calc.rb” i have to put “ruby.rb.txt”

04 Apr 2012, 15:04
Generic-user-small

windwaves (1 post)

Can we use this book with Macs ? What I mean of course is, can we install Ruby and practice and go over the examples on my Mac(s) ? thx

15 May 2013, 19:43
Generic-user-small

Oscar Lopez (1 post)

Hello Chris I am still stuck on this I have windows 8 and although I have found the ruby version on cmd line I have yet to run the simple program. Although I type in “calc.rb” to its file name the extension remains as .txt. This confuses me on what should be the correct directory since I keep getting the same message that no file or directory exists. Please clarify this has caused me lots of frustration trying to solve why it does not run.

16 May 2013, 19:46
Med__2008.08.19.09.44.43_pragsmall

Chris Pine (58 posts)

I’m sorry, but I don’t have Windows 8, so I’m not sure how to rename the file extension. If you can find it on the command line, you can use the “move” command, which also renames:

@c:\Users\chris> move calc.txt calc.rb@

Hope that helps,

Chris

22 May 2013, 04:19
Generic-user-small

Allan Shoo (1 post)

I have window 7 and I am facing the same issue, is there any one that was able to fix this.. I am stuck, please help

22 May 2013, 16:24
Med__2008.08.19.09.44.43_pragsmall

Chris Pine (58 posts)

Again, I know the first chapter isn’t terribly exciting, but the answers are there, I promise! Your problems are all about learning how to use the command line.

If Ruby can’t find @calc.rb@, that means that you aren’t in the directory where you saved @calc.rb@ . You need to navigate to the correct directory using the @cd@ command.

You’ll know that you’ve found it when you can see your program listed when you use the @dir@ command (or, if you’re using Linux or OSX, the @ls@ command).

That’s the short version; the long version is called Chapter 1. :-)

Good luck!

25 Jun 2013, 03:06
Generic-user-small

Jesse Jimenez (1 post)

Yes; I too got stuck but I figured it out (on Windows 7 OS). Here it goes, explained:

First off, I made a desktop folder, named Jesse’s Programs Folder. Second, I made my “calc” file into calc.txt format because windows 7 made it difficult to attempt to make the file into a ruby file. But no matter! Here’s what I figured out to do:

My command line looks similar to this (and the steps I took to solve my problem):

Step 1: By default my command line reads this: C:\Users\Jesse Jimenez>

Step 2: I did the following command: C:\Users\Jesse Jimenez> cd desktop

Step 3: C:\Users\Jesse Jimenez\Desktop> cd Jesse’s Programs Folder

Step 4: I then use “dir/ad” to find my file under my directory on ruby: “C:\Users\Jesse Jimenez\Desktop\Jesse’s Programs Folder> dir/ad” to find my file under the command line and I found it based on the approximate time and date I saved the file and the name of the file.

Step 5: I then did this command: “C:\Users\Jesse Jimenez\Desktop\Jesse’s Programs Folder>move calc.txt calc.rb” and the a command prompt stated that my file had changed from a .txt file to a .rb file

Step 6: Finally, I did this: “C:\Users\Jesse Jimenez\Desktop\Jesse’s Programs Folder>ruby calc.rb” At last, I got the calculation of 3!

Hope this all helps!

21 Aug 2013, 15:30
Generic-user-small

Alan Kitchen (1 post)

Just a quick comment that I hope may help other beginners:

When using Windows Notepad to save a file, it automatically adds .txt as an extension. Even when you already tell it to save the file “somefile.rb”, it will save the file as “somefile.rb.txt” - this is most annoying.

So you have to rename the file to “somefile.rb” either by changing to the directory where the file is and using the move command on the command line or by browsing to the folder in the windows GUI, right-clicking on the file and using the rename menu entry.

In the book, Chris recommends notepad++ for Windows programming. This does not have this behaviour, and I also recommend it. It is a good general, flexible programming environment and is released as free software under a GNU licence.

  You must be logged in to comment