如何在外部设置Ruby的加载路径 [英] How to set Ruby's load path externally

查看:92
本文介绍了如何在外部设置Ruby的加载路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个自定义的Ruby库目录,我希望在执行Ruby时将其自动添加到Ruby的加载路径中.我知道我可以对Ruby使用-I选项,但是是否可以设置诸如环境变量之类的东西来全局确定Ruby的加载路径.

I have a custom Ruby library directory that I'd like to have automatically added to Ruby's load path whenever Ruby is executed. I know I can use the -I option to Ruby, but is there something like an environment variable that I can set that will globally determine Ruby's load path.

我想在没有root特权的Linux机器上安装Ruby Gems,因此我需要在非标准位置安装Ruby加载路径.我按照"在用户目录中安装RubyGems "安装了RubyGems,但是gem命令没有选择非标准的加载路径.

I want to install Ruby Gems on a Linux box where I don't have root privileges, so I need to have a Ruby load path in a non-standard location. I installed RubyGems per "Installing RubyGems in a User Directory", but the gem command isn't picking up the non-standard load path.

也许我在这里遗漏了一些明显的东西并使我自己变得更难?

Maybe I'm missing something obvious here and making things harder for myself?

推荐答案

请参阅" Ruby及其世界"一章,特别是关于环境变量的部分.摘录:

See the "Ruby and Its World" chapter from The Pickaxe Book, specifically the section on environment variables. Excerpt:

RUBYLIB 
  Additional search path for Ruby programs ($SAFE must be 0).
DLN_LIBRARY_PATH
  Search path for dynamically loaded modules.
RUBYLIB_PREFIX
  (Windows only) Mangle the RUBYLIB search path by adding this
  prefix to each component.

这篇关于如何在外部设置Ruby的加载路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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