From 96204383c7720d28e049a429895baf049bbf3eb7 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 3 Mar 2017 09:12:44 -0800 Subject: [PATCH 1/2] Force path as preferred source on local install --- lib/vagrant/bundler.rb | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 563454786..2c0403f3b 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -3,6 +3,7 @@ require "pathname" require "set" require "tempfile" require "fileutils" +require "uri" require "rubygems/package" require "rubygems/uninstaller" @@ -113,7 +114,7 @@ module Vagrant plugin_source.spec.name => { "gem_version" => plugin_source.spec.version.to_s, "local_source" => plugin_source, - "sources" => opts.fetch(:sources, Gem.sources.map(&:to_s)) + "sources" => opts.fetch(:sources, []) } } @logger.debug("Installing local plugin - #{plugin_info}") @@ -209,9 +210,6 @@ module Vagrant protected def internal_install(plugins, update, **extra) - # Only allow defined Gem sources - Gem.sources.clear - update = {} if !update.is_a?(Hash) skips = [] source_list = {} @@ -225,11 +223,12 @@ module Vagrant else gem_version = info['gem_version'].to_s.empty? ? '> 0' : info['gem_version'] end + source_list[name] ||= [] if plugin_source = info.delete("local_source") installer_set.add_local(plugin_source.spec.name, plugin_source.spec, plugin_source) + source_list[name] << plugin_source.path end Array(info["sources"]).each do |source| - source_list[name] ||= [] if !source.end_with?("/") source = source + "/" end @@ -244,8 +243,12 @@ module Vagrant default_sources = DEFAULT_GEM_SOURCES & all_sources all_sources -= DEFAULT_GEM_SOURCES + # Only allow defined Gem sources + Gem.sources.clear + @logger.debug("Enabling user defined remote RubyGems sources") all_sources.each do |src| + next if URI.parse(src).scheme.nil? @logger.debug("Adding RubyGems source #{src}") Gem.sources << src end @@ -255,9 +258,10 @@ module Vagrant @logger.debug("Adding source - #{src}") Gem.sources << src end + source_list.values.each{|srcs| srcs.delete_if{|src| default_sources.include?(src)}} installer_set.prefer_sources = source_list - @logger.debug("Current source list for install: #{Gem.sources}") + @logger.debug("Current source list for install: #{Gem.sources.to_a}") # Create the request set for the new plugins request_set = Gem::RequestSet.new(*plugin_deps) @@ -401,8 +405,16 @@ module Vagrant def find_all(req) result = super subset = result.find_all do |idx_spec| - prefer_sources[req.name] && - prefer_sources[req.name].include?(idx_spec.source.uri.to_s) + preferred = false + if prefer_sources[req.name] + if idx_spec.source.respond_to?(:path) + preferred = prefer_sources[req.name].include?(idx_spec.source.path.to_s) + end + if !preferred + preferred = prefer_sources[req.name].include?(idx_spec.source.uri.to_s) + end + end + preferred end subset.empty? ? result : subset end From 8a9fa302f08a248c73d3ec133dfe65b5f7a9a16f Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 3 Mar 2017 09:49:55 -0800 Subject: [PATCH 2/2] Removing timing issues from test coverage --- test/unit/vagrant/util/subprocess_test.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/unit/vagrant/util/subprocess_test.rb b/test/unit/vagrant/util/subprocess_test.rb index c3686db76..d20a7fffd 100644 --- a/test/unit/vagrant/util/subprocess_test.rb +++ b/test/unit/vagrant/util/subprocess_test.rb @@ -64,10 +64,11 @@ describe Vagrant::Util::Subprocess do end context "when subprocess is running" do it "should return true" do - sp = described_class.new("sleep", "0.2") + sp = described_class.new("sleep", "5") thread = Thread.new{ sp.execute } sleep(0.1) expect(sp.running?).to be_true + sp.stop thread.join end end