Require team not to work in bash irb on Snow Leopard

I am working on Zed Shaw Learn Ruby the Hard Way Exercise 25

http://ruby.learncodethehardway.org/ex25.html

When I go to the directory where the ruby โ€‹โ€‹file ex25.rb is stored and IRB starts up, I get the following errors:

Larson-2:~ larson$ cd Ruby Larson-2:Ruby larson$ ls ex25.rb Larson-2:Ruby larson$ irb ruby-1.9.2-p290 :001 > require 'ex25' LoadError: no such file to load -- ex25 from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from (irb):1 from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>' ruby-1.9.2-p290 :002 > 

The require command doesn't seem to work here. Is something missing?

I also tried using "./25" as suggested, and getting these errors:

 Larson-2:Ruby larson$ irb ruby-1.9.2-p290 :001 > require './ex25' SyntaxError: /Users/larson/Ruby/ex25.rb:1: invalid multibyte char (US-ASCII) from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require' from (irb):1 from /Users/larson/.rvm/rubies/ruby-1.9.2-p290/bin/irb:16:in `<main>' 
+7
source share
2 answers

This is because the working directory is no longer in the Ruby path in Ruby 1.9.2. It works:

 require './ex25' 
+14
source

This is actually a mistake on my part when I wrote the exercise. @mischa is in place with his solution, but you will notice how you progress through the book, in the subsequent exercises use the require_relative command instead of require .

Various methods for ensuring that your working directory is on the download path are described here , but I suggest you choose one and stay consistent.

+2
source

All Articles