From 5b9bc086ac86b42f7a970e4fe7c3d65ae188f9d7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 5 Oct 2010 13:40:09 -0700 Subject: [PATCH] Fix plugin loading in a Rails 2.3.x project [closes GH-176] --- CHANGELOG.md | 2 +- lib/vagrant/plugin.rb | 15 +++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 98644c1a1..53dc978a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ ## 0.6.5 (unreleased) - + - Fix plugin loading in a Rails 2.3.x project. [GH-176] ## 0.6.4 (October 4, 2010) diff --git a/lib/vagrant/plugin.rb b/lib/vagrant/plugin.rb index a33686748..5df4e89d0 100644 --- a/lib/vagrant/plugin.rb +++ b/lib/vagrant/plugin.rb @@ -21,13 +21,20 @@ module Vagrant # load path. This file is loaded to kick off the load sequence # for that plugin. def self.load! + # Stupid hack since Rails 2.3.x overrides Gem.source_index with their + # own incomplete replacement which causes issues. + index = Gem.source_index + index = [index.installed_source_index, index.vendor_source_index] if defined?(Rails::VendorGemSourceIndex) && index.is_a?(Rails::VendorGemSourceIndex) + # Look for a vagrant_init.rb in all the gems, but only the # latest version of the gems. - Gem.source_index.latest_specs.each do |spec| - file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first - next if !file + [index].flatten.each do |source| + source.latest_specs.each do |spec| + file = Gem.searcher.matching_files(spec, "vagrant_init.rb").first + next if !file - @@plugins << new(spec, file) + @@plugins << new(spec, file) + end end end