在检查了一个新版本的 repo 之后,我发现我在一个 rake 任务中遇到了一个未定义的方法错误,该任务曾经对我有用,也适用于其他所有人。以下代码被调用,并引发此错误:undefined method 'source_index' for Gem:Module
. 然而Gem.source_index
似乎已经明确定义。
module Gem
def self.source_index=(index)
@@source_index = index
end
end
module Rails
class GemDependency < Gem::Dependency
attr_accessor :lib, :source, :dep
def self.unpacked_path
@unpacked_path ||= File.join(RAILS_ROOT, 'vendor', 'gems')
end
@@framework_gems = {}
def self.add_frozen_gem_path
@@paths_loaded ||= begin
source_index = Rails::VendorGemSourceIndex.new(Gem.source_index) // ERROR HERE
Gem.clear_paths
Gem.source_index = source_index
# loaded before us - we can't change them, so mark them
Gem.loaded_specs.each do |name, spec|
@@framework_gems[name] = spec
end
true
end
end