0

我正在尝试加载 ruby​​write 并运行其中一个示例,但这给我带来了以下错误:-

/usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- rubywrite/exceptions (LoadError)
    from /usr/local/lib/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
    from /home/ankit/Downloads/Studies/PLI/Assignment2/RubyWrite/lib/rubywrite.rb:1:in `<top (required)>'
    from pcc.rb:4:in `require_relative'
    from pcc.rb:4:in `<main>'

我不确定需要做什么。我的 Ruby 版本是:

- ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

我的宝石环境是:-

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.25
  - RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /usr/bin/ruby1.9.1
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.9.1
     - /home/ankit/.gem/ruby/1.9.1
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :benchmark => false
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
4

2 回答 2

1

默认情况下,当前目录不包含在库包含路径中。

-I您可以使用以下选项在 Ruby 命令行上显式添加它:

ruby -I. the_file.rb
于 2013-02-02T18:24:37.097 回答
0

使用“require_relative”并指定要包含的文件的完整路径。问题是'require' 只查看Ruby 库路径中的文件。另请参阅:Ruby 中的 require_relative 和 require 有什么区别?

于 2013-02-02T21:52:19.567 回答