diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index c6c19da87..24031cb37 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -139,14 +139,15 @@ module Vagrant # # @param [String] path Path to a local gem file. # @return [Gem::Specification] - def install_local(path) + def install_local(path, opts={}) plugin_source = Gem::Source::SpecificFile.new(path) plugin_info = { plugin_source.spec.name => { - 'local_source' => plugin_source + "local_source" => plugin_source, + "sources" => opts.fetch(:sources, Gem.sources.map(&:to_s)) } } - internal_install(plugin_info, {}, local_install: true) + internal_install(plugin_info, {}) plugin_source.spec end @@ -223,9 +224,8 @@ module Vagrant protected def internal_install(plugins, update, **extra) - - # Only clear Gem sources if not performing local install - Gem.sources.clear if !extra[:local_install] + # Only allow defined Gem sources + Gem.sources.clear update = {} unless update.is_a?(Hash) installer_set = Gem::Resolver::InstallerSet.new(:both) diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb index ca9be34c5..76ce74dcc 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -44,7 +44,7 @@ module Vagrant local = false if name =~ /\.gem$/ # If this is a gem file, then we install that gem locally. - local_spec = Vagrant::Bundler.instance.install_local(name) + local_spec = Vagrant::Bundler.instance.install_local(name, opts) name = local_spec.name opts[:version] = local_spec.version.to_s end