Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Load plugins with the private gem path.

This changed plugin loading semantics a tiny bit, since they are
no longer loaded when Vagrant is loaded but instead when the
Vagrant::Environment is initialized. I'll note this in the CHANGELOG.
  • Loading branch information...
commit 13fddfa6f9766ee85f9494c9a12580411f48fa07 1 parent 261a83d
@mitchellh mitchellh authored
View
7 lib/vagrant.rb
@@ -50,6 +50,9 @@
# there are issues with ciphers not being properly loaded.
require 'openssl'
+# Always make the version available
+require 'vagrant/version'
+
module Vagrant
autoload :Action, 'vagrant/action'
autoload :Box, 'vagrant/box'
@@ -186,7 +189,3 @@ def self.provisioners
Vagrant.config_keys.register(:freebsd) { Vagrant::Guest::FreeBSD::FreeBSDConfig }
Vagrant.config_keys.register(:linux) { Vagrant::Guest::Linux::LinuxConfig }
Vagrant.config_keys.register(:solaris) { Vagrant::Guest::Solaris::SolarisConfig }
-
-# Load the things which must be loaded before anything else.
-require 'vagrant/version'
-Vagrant::Plugin.load!
View
15 lib/vagrant/environment.rb
@@ -88,6 +88,9 @@ def initialize(opts=nil)
# Setup the default private key
@default_private_key_path = @home_path.join("insecure_private_key")
copy_insecure_private_key
+
+ # Load the plugins
+ load_plugins
end
#---------------------------------------------------------------
@@ -494,5 +497,17 @@ def find_vagrantfile(search_path)
nil
end
+
+ # Loads the Vagrant plugins by properly setting up RubyGems so that
+ # our private gem repository is on the path.
+ def load_plugins
+ # Add our private gem path to the gem path and reset the paths
+ # that Rubygems knows about.
+ ENV["GEM_PATH"] = "#{@gems_path}:#{ENV["GEM_PATH"]}"
+ ::Gem.clear_paths
+
+ # Load the plugins
+ Plugin.load!
+ end
end
end
View
26 lib/vagrant/plugin.rb
@@ -9,15 +9,9 @@ module Vagrant
# (for debugging), the list of loaded plugins is stored in the {plugins}
# array.
class Plugin
- # The array of loaded plugins.
+ # The array of gem specifications that were loaded as plugins.
@@plugins = []
- # The gemspec of this plugin. This is an actual gemspec object.
- attr_reader :gemspec
-
- # The path to the `vagrant_init.rb` file which was loaded for this plugin.
- attr_reader :file
-
# Loads all the plugins for Vagrant. Plugins are currently
# gems which have a "vagrant_init.rb" somewhere on their
# load path. This file is loaded to kick off the load sequence
@@ -46,6 +40,11 @@ def self.load!
specs = Gem::VERSION >= "1.6.0" ? source.latest_specs(true) : source.latest_specs
specs.each do |spec|
+ if @@plugins.include?(spec)
+ logger.debug("Plugin already loaded, not loading again: #{spec.name}")
+ next
+ end
+
# If this gem depends on Vagrant, verify this is a valid release of
# Vagrant for this gem to load into.
vagrant_dep = spec.dependencies.find { |d| d.name == "vagrant" }
@@ -65,7 +64,8 @@ def self.load!
next if !file
logger.info("Loading plugin: #{spec.name} (#{spec.version})")
- @@plugins << new(spec, file)
+ @@plugins << spec
+ load file
end
logger.info("Loaded #{@@plugins.length} plugins.")
@@ -77,15 +77,5 @@ def self.load!
#
# @return [Array]
def self.plugins; @@plugins; end
-
- # Initializes a new plugin, given a Gemspec and the path to the
- # gem's `vagrant_init.rb` file. This should never be called manually.
- # Instead {load!} creates all the instances.
- def initialize(spec, file)
- @gemspec = spec
- @file = file
-
- load file
- end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.