0

如何添加“。” 永久到我的红宝石加载路径。我不关心安全问题,只要在会话期间永久保存它就可以了。并且请不要告诉我使用 require_relative 或那种。我有大量的需求。一次改变它们很棘手。我只需要'。在路上。谢谢!

4

2 回答 2

1

Set the RUBYLIB environment variable for your shell to include the current path .. If you want multiple paths to search from, you can separate each path with :.

export RUBYLIB=.

Test:

$ RUBYLIB='.' ruby -e "p $:"

UPDATE: Put the environment variable settings in your shell's initialization script so that it gets set every time you launch your shell.

于 2013-06-06T01:32:48.203 回答
0

$:.unshift File.dirname(__FILE__)

Should add the directory of the file you place the snippet on.

If you want the directory where you are currently working on (where you call the file from) you can do the following:

$:.unshift Dir.getwd

于 2013-06-06T01:26:42.600 回答