user2785673
user2785673

Reputation: 23

Loading .rb files in Mac OS IRB

I'm just staring out with Ruby. I followed a tutorial to set up Ruby environment on my Mac OS. Then, I created a file named 'personal_chef.rb' in Sublime Text and saved it to a folder I created. Next went to IRB and tried "load 'personal_chef.rb'" and got the error:

-bash: load: command not found

I think it might have to do with how I switched my PATH when installing a new version of git during Environment setup. (I did that by following their instructions and typing: 'echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile').

Can someone please help explain what is happening and how I can fix it? Basically I want to be able to create a file in Sublime Text, save it, then load it in IRB.

(I am running Mac OS 10.7.5, using Sublime Text 2.0.2 and using Terminal.app for IRB).

Thanks!

Upvotes: 0

Views: 2832

Answers (1)

Jake Sendar
Jake Sendar

Reputation: 194

This is how you load the file:

First, make sure you enter the irb command from within the same directory you saved 'personal_chef.rb'.

This means that if you saved it to your desktop, you would type ~/desktop

You'll know you're in irb if your command line beings with irb(main)

Next simply type load 'personal_chef.rb'

If you successfully loaded the file the load method will return true.

Upvotes: 2

Related Questions