什么是“需要"路径?默认情况下查找? [英] What are the paths that "require" looks up by default?
本文介绍了什么是“需要"路径?默认情况下查找?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在Ruby中,有人告诉我这样做的时候
In Ruby, I have been told that when doing
require "some_file"
Ruby将在某些位置查找文件.
Ruby will look for the file in certain places.
我知道它在寻找some_file.rb
,但是默认情况下它在哪里寻找?
I know that it looks for some_file.rb
, but where does it look for it by default?
推荐答案
这取决于您的平台以及Ruby的编译方式,因此没有"the"答案.您可以通过运行以下内容找出答案:
It depends on your platform, and how Ruby was compiled, so there is no "the" answer to this. You can find out by running:
ruby -e 'puts $:'
但是,通常,您具有标准,站点和供应商的Ruby库路径,包括每个路径下的arch,版本和常规目录.
Generally, though, you have the standard, site, and vendor Ruby library paths, including an arch, version, and general directory under each.
这篇关于什么是“需要"路径?默认情况下查找?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文