Only use Gem sources that are provided

This commit is contained in:
Chris Roberts 2016-11-11 14:50:20 -08:00
parent 1691e3af58
commit bd3f0c442c
2 changed files with 7 additions and 7 deletions

View File

@ -139,14 +139,15 @@ module Vagrant
# #
# @param [String] path Path to a local gem file. # @param [String] path Path to a local gem file.
# @return [Gem::Specification] # @return [Gem::Specification]
def install_local(path) def install_local(path, opts={})
plugin_source = Gem::Source::SpecificFile.new(path) plugin_source = Gem::Source::SpecificFile.new(path)
plugin_info = { plugin_info = {
plugin_source.spec.name => { 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 plugin_source.spec
end end
@ -223,9 +224,8 @@ module Vagrant
protected protected
def internal_install(plugins, update, **extra) def internal_install(plugins, update, **extra)
# Only allow defined Gem sources
# Only clear Gem sources if not performing local install Gem.sources.clear
Gem.sources.clear if !extra[:local_install]
update = {} unless update.is_a?(Hash) update = {} unless update.is_a?(Hash)
installer_set = Gem::Resolver::InstallerSet.new(:both) installer_set = Gem::Resolver::InstallerSet.new(:both)

View File

@ -44,7 +44,7 @@ module Vagrant
local = false local = false
if name =~ /\.gem$/ if name =~ /\.gem$/
# If this is a gem file, then we install that gem locally. # 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 name = local_spec.name
opts[:version] = local_spec.version.to_s opts[:version] = local_spec.version.to_s
end end