2

卡住了,找不到原因,应该很简单,

这是错误消息:

require': 没有要加载的文件 -- ./ip (LoadError)

它是由这行代码生成的:

require './ip'

由于 require 'socket' 有效,我找到了两个库:

/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip.rb
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib/ip /socket.rb

require 'ip' 也 试过了require '../ip'

还是一样的错误


背景资料:

我安装了 ruby​​-ip 以便可以调用如下方法: ip = IP.new do ...

gem安装了ruby-ip

我可以看到图书馆(我相信这是我需要使用的 ip.rb;

密码
/usr/lib/ruby/gems/1.8/gems/ruby-ip-0.9.1/lib
ls
ip ip.rb

环境信息

ruby -v
ruby 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]

宝石清单

*** LOCAL GEMS ***

builder (3.2.0)
eventmachine (1.0.1, 0.12.10)
pg (0.14.1, 0.13.2)
ruby-ip (0.9.1)
rubygems-update (2.0.0)
sqlite3 (1.3.3)

哪个红宝石

/usr/bin/红宝石

哪个宝石

/usr/bin/gem

宝石环境

RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.0
  - RUBY VERSION: 1.8.7 (2012-10-12 patchlevel 371) [i386-linux]
  - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8
  - RUBY EXECUTABLE: /usr/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86-linux
  - GEM PATHS:
     - /usr/lib/ruby/gems/1.8
     - /home/pilar/.gem/ruby/1.8
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - http://rubygems.org/
4

1 回答 1

0

你是否也包括需要'rubygems'?如果您使用的是 rvm,则它是必需的。

例子:

[fotanus@thing ~]$ gem install ip
Fetching: ip-0.3.0.gem (100%)
Successfully installed ip-0.3.0
1 gem installed
Installing ri documentation for ip-0.3.0...
Installing RDoc documentation for ip-0.3.0...
[fotanus@thing ~]$ irb
1.8.7 :001 > require 'ip'
LoadError: no such file to load -- ip
    from (irb):1:in `require'
    from (irb):1
1.8.7 :002 > require 'rubygems'
 => true 
1.8.7 :003 > require 'ip'
 => true 
1.8.7 :004 > 
于 2013-04-09T20:07:22.180 回答