core: when installig local plugins, don't fetch remote

This commit is contained in:
Mitchell Hashimoto 2014-01-06 10:52:14 -08:00
parent 5197d3d86f
commit 3cefcda1e3
2 changed files with 7 additions and 4 deletions

View File

@ -58,8 +58,8 @@ module Vagrant
#
# @param [Hash] plugins
# @return [Array<Gem::Specification>]
def install(plugins)
internal_install(plugins, nil)
def install(plugins, local=false)
internal_install(plugins, nil, local: local)
end
# Installs a local '*.gem' file so that Bundler can find it.
@ -180,12 +180,13 @@ module Vagrant
# @param [Hash, Boolean] update If true, updates all plugins, otherwise
# can be a hash of options. See Bundler.definition.
# @return [Array<Gem::Specification>]
def internal_install(plugins, update)
def internal_install(plugins, update, **extra)
gemfile = build_gemfile(plugins)
lockfile = "#{gemfile.path}.lock"
definition = ::Bundler::Definition.build(gemfile, lockfile, update)
root = File.dirname(gemfile.path)
opts = {}
opts["local"] = true if extra[:local]
with_isolated_gem do
::Bundler::Installer.install(root, definition, opts)

View File

@ -29,11 +29,13 @@ module Vagrant
# @param [String] name Name of the plugin (gem)
# @return [Gem::Specification]
def install_plugin(name, **opts)
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)
name = local_spec.name
opts[:version] = "= #{local_spec.version}"
local = true
end
plugins = installed_plugins
@ -45,7 +47,7 @@ module Vagrant
result = nil
install_lambda = lambda do
Vagrant::Bundler.instance.install(plugins).each do |spec|
Vagrant::Bundler.instance.install(plugins, local).each do |spec|
next if spec.name != name
next if result && result.version >= spec.version
result = spec