gpt4 book ai didi

ruby - 为什么找不到库: no such file to load

转载 作者:太空宇宙 更新时间:2023-11-03 16:53:46 24 4
gpt4 key购买 nike

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

这是错误信息:

require': no such file to load -- ./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

也尝试过需要'ip'需要'../ip'

还是一样的错误


背景信息:

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

gem installed 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]

gem list

*** 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)

哪个 ruby

/usr/bin/ ruby

哪个 gem

/usr/bin/gem

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/

最佳答案

您是否也包括 require '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 >

关于ruby - 为什么找不到库: no such file to load,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15194433/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com