diff --git a/bin/vagrant b/bin/vagrant index 2e12f0d76..0f017ee69 100755 --- a/bin/vagrant +++ b/bin/vagrant @@ -39,6 +39,10 @@ if argv.include?("--debug") ENV["VAGRANT_LOG"] = "debug" end +# Setup our dependencies by initializing Bundler +require "bundler" +Bundler.setup + require 'log4r' require 'vagrant' require 'vagrant/cli' diff --git a/lib/vagrant.rb b/lib/vagrant.rb index b7c870526..83c801c89 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -261,4 +261,4 @@ Vagrant.source_root.join("plugins").children(true).each do |directory| end # If we have plugins enabled, then load those -Bundler.require(:default) if Vagrant.plugins_enabled? +Bundler.require(:plugins) if Vagrant.plugins_enabled? diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 4659a8085..956735be1 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -39,9 +39,8 @@ module Vagrant "#{Vagrant.user_data_path.join("gems")}#{::File::PATH_SEPARATOR}#{@gem_path}" Gem.clear_paths - # Load Bundler and setup our paths + # Load Bundler now require "bundler" - ::Bundler.setup # Do some additional Bundler initialization ::Bundler.ui = ::Bundler::UI.new @@ -70,7 +69,7 @@ module Vagrant # Clean up any unused/old gems runtime = ::Bundler::Runtime.new(root, definition) - runtime.clean + #runtime.clean definition.specs end @@ -85,9 +84,11 @@ module Vagrant gemfile.puts(%Q[source "https://rubygems.org"]) gemfile.puts(%Q[source "http://gems.hashicorp.com"]) gemfile.puts(%Q[gem "vagrant", "= #{Vagrant::VERSION}"]) + gemfile.puts("group :plugins do") plugins.each do |plugin| gemfile.puts(%Q[gem "#{plugin}"]) end + gemfile.puts("end") gemfile.close end end diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb index 20ff87d25..3f7d5beb9 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -25,6 +25,7 @@ module Vagrant # Installs another plugin into our gem directory. # # @param [String] name Name of the plugin (gem) + # @return [Gem::Specification] def install_plugin(name) result = nil Vagrant::Bundler.instance.install(installed_plugins.push(name)).each do |spec| @@ -33,6 +34,9 @@ module Vagrant result = spec end + # Add the plugin to the state file + @global_file.add_plugin(result.name) + result end