我正在编写 Zed Shaw 的 Learn Ruby the Hard Way 练习 25
http://ruby.learncodethehardway.org/ex25.html
当我导航到包含 ruby 文件 ex25.rb 的目录并启动 IRB 时,我收到以下错误:
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 >
似乎 require 命令在这里不起作用。有什么我想念的吗?
我还按照建议尝试了 require './25' 并得到了这些错误:
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>'