Debugging LoadError Message

So I saved the below text as a “ex3.rb” file in my home directory :

puts “I will now count my chickens:”

puts “Hens #{25 + 30 / 6}”
puts “Roosters #{100 - 25 * 3 % 4}”

puts “Now I will count the eggs:”

puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

puts “Is it true that 3 + 2 < 5 - 7?”

puts 3 + 2 < 5 - 7

puts “What is 3 + 2? #{3 + 2}”
puts “What is 5 - 7? #{5 - 7}”

puts “Oh, that’s why it’s false.”

puts “How about some more.”

puts “Is it greater? #{5 > -2}”
puts “Is it greater or equal? #{5 >= -2}”
puts “Is it less or equal? #{5 <= -2}”

Tried to run it in my Terminal by typing :

CaiGengYangs-MacBook-Pro:mystuff CaiGengYang$ cd ~/mystuff
CaiGengYangs-MacBook-Pro:mystuff CaiGengYang$ ruby ex3.rb

But I got this error message — ruby : No such file or directory – ex3.rb (LoadError)

How to debug this ?

You have to be in the directory where you stored the file. If you type dir and hit enter and don’t see the file there you’re in the wrong directory.

Where do I type “dir” to check if the file is in there again ?

Sorry for noob question … i keep forgetting. Play too much computer game just now, forgot … so addictive

lol … need to cut down on the computer games.

You should research using your Mac terminal shell and how to navigate your directories, find files, and run them. This is currently what you don’t understand and this is something you need to learn. And the best way is through experience and practice. When you have a question about using the shell do a Google search, watch some youtube videos, read some beginner blogs. This is something I had to learn as a child and I didn’t have internet to figure it out. Take your time experimenting and you will learn it well.

1 Like