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

查看:23
本文介绍了如何在外部设置 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 及其世界"来自 The Pickaxe Book 的章节,特别是关于环境变量的部分.摘录:

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天全站免登陆