红宝石需要问题(与$ LOAD_PATH有关) [英] ruby require problem (something to do with $LOAD_PATH)

查看:104
本文介绍了红宝石需要问题(与$ LOAD_PATH有关)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试使用我刚刚安装的宝石(通过 sudo gem install excelsior )像这样


需要'rubygems'



需要'excelsior'

...

这在irb中可以正常工作,但是当我将完全相同的代码粘贴到.rb文件并尝试使用ruby运行时, code>< internal:lib / ruby​​gems / 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆