在执行ruby脚本期间加载gem

时间:2015-01-12 11:03:07

标签: ruby gem

当尝试加载已经加载宝石的ruby脚本执行中途安装的gem时,无法找到已安装的gem。我查看了Gem::Specification的源代码,并在阅读器上查找了all类变量,对已缓存的gemspec文件进行了扫描。

使用Gem::Specification.all = nil重置此变量有效,但附带此评论:

##
# Sets the known specs to +specs+. Not guaranteed to work for you in
# the future. Use at your own risk. Caveat emptor. Doomy doom doom.
# Etc etc.
#
#--
# Makes +specs+ the known specs
# Listen, time is a river
# Winter comes, code breaks
#
# -- wilsonb

def self.all= specs
  @@all = specs
end

我想知道是否有更好的方式。

0 个答案:

没有答案