红宝石需要问题(与$ LOAD_PATH有关) [英] ruby require problem (something to do with $LOAD_PATH)
问题描述
我尝试使用我刚刚安装的宝石(通过 sudo gem install excelsior
)像这样
需要'rubygems'
需要'excelsior'
...
这在irb中可以正常工作,但是当我将完全相同的代码粘贴到.rb文件并尝试使用ruby运行时, code>< internal:lib / rubygems / custom_require>:29:in require':no such file to load - excelsior(LoadError)
我认为它与加载路径显然与ruby的irb完全不同(我在Mac上,不记得我是如何安装我使用的ruby版本的)。
那么如何配置ruby使其具有与irb相同的加载路径?
一条额外的信息:一些宝石的工作,但不是全部:S
要查看两个可执行文件是否是不同版本的ruby d),请求它做
puts RUBY_VERSION
I'm trying to use a gem i just installed (via sudo gem install excelsior
) like so
require 'rubygems'
require 'excelsior'
...
This works fine in irb, but when I stick exactly the same code into an .rb file and try run it with ruby I get <internal:lib/rubygems/custom_require>:29:in require': no such file to load -- excelsior (LoadError)
I guess it has something to do with the load paths apparently being completely different in irb from ruby (I'm on a mac and don't remember exactly how I installed the version of ruby I'm using).
So how do I configure ruby to have the same loadpath as irb?
One extra piece of info: some gems work, but not all :S
To see if the two executables are different versions of ruby (as suspected by some), ask it to do
puts RUBY_VERSION
这篇关于红宝石需要问题(与$ LOAD_PATH有关)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!