diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 1773081de..92a06fa0c 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -58,8 +58,8 @@ module Vagrant # # @param [Hash] plugins # @return [Array] - 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] - 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) diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb index acb2352d1..5b708c88a 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -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