需要命令在雪豹上的 bash irb 中不起作用 [英] Require command not working within bash irb on Snow Leopard
本文介绍了需要命令在雪豹上的 bash irb 中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在学习 Zed Shaw 的 Learn Ruby the Hard Way 练习 25
I am working on Zed Shaw's Learn Ruby the Hard Way Exercise 25
http://ruby.learncodethehardway.org/ex25.html
当我导航到保存 ruby 文件 ex25.rb 的目录并启动 IRB 时,出现以下错误:
When I navigate to the directory that holds the ruby file ex25.rb and launch IRB, I get these 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 >
似乎 require 命令在这里不起作用.有什么我遗漏的吗?
It seems that the require command isn't working here. Is there something I am missing?
我也按照建议尝试了 require './25' 并得到这些错误:
I also tried require './25' as suggested and get 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>'
推荐答案
这是因为 工作目录不再位于 Ruby 路径 在 Ruby 1.9.2 中.这确实有效:
This is because the working directory is no longer in the Ruby path in Ruby 1.9.2. This does work:
require './ex25'
这篇关于需要命令在雪豹上的 bash irb 中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文