我被困住了,找不到原因,这被认为很简单,
这是错误消息:
require':没有要加载的文件 - ./ip(LoadError)
这是由这行代码生成的:
require './ip'
作为 要求'插座' 工作,我找到了两个库:
/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;
PWD
/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)
哪个红宝石
哪个宝石
宝石环境
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/
答案 0 :(得分: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 >