From abf38106c0a35e0e77982f7c2cd49cf1f5a54c23 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 7 Mar 2017 10:36:14 -0800 Subject: [PATCH 1/2] Add shared helper method to detect if running version is prerelease --- lib/vagrant/shared_helpers.rb | 8 ++++++++ test/unit/vagrant/shared_helpers_test.rb | 12 ++++++++++++ 2 files changed, 20 insertions(+) diff --git a/lib/vagrant/shared_helpers.rb b/lib/vagrant/shared_helpers.rb index ffe61e571..c5d6ea617 100644 --- a/lib/vagrant/shared_helpers.rb +++ b/lib/vagrant/shared_helpers.rb @@ -102,4 +102,12 @@ module Vagrant Pathname.new(path).expand_path end + + # This returns true/false if the running version of Vagrant is + # a pre-release version (development) + # + # @return [Boolean] + def self.prerelease? + Gem::Version.new(Vagrant::VERSION).prerelease? + end end diff --git a/test/unit/vagrant/shared_helpers_test.rb b/test/unit/vagrant/shared_helpers_test.rb index c64a26001..2ebfc76a5 100644 --- a/test/unit/vagrant/shared_helpers_test.rb +++ b/test/unit/vagrant/shared_helpers_test.rb @@ -131,4 +131,16 @@ describe Vagrant do end end end + + describe "#prerelease?" do + it "should return true when Vagrant version is development" do + stub_const("Vagrant::VERSION", "1.0.0.dev") + expect(subject.prerelease?).to be(true) + end + + it "should return false when Vagrant version is release" do + stub_const("Vagrant::VERSION", "1.0.0") + expect(subject.prerelease?).to be(false) + end + end end From 7610ecfcba27f8f797585b3b3b05a1bd2a02c52d Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Tue, 7 Mar 2017 10:36:35 -0800 Subject: [PATCH 2/2] Allow prerelease matches on vagrant spec when running instance is prerelease --- lib/vagrant/bundler.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 563454786..7a02b011a 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -280,7 +280,10 @@ module Vagrant # as we know the dependencies are satisfied and it will attempt to validate a gem's # dependencies are satisified by gems in the install directory (which will likely not # be true) - result = request_set.install_into(plugin_gem_path.to_s, true, ignore_dependencies: true) + result = request_set.install_into(plugin_gem_path.to_s, true, + ignore_dependencies: true, + prerelease: Vagrant.prerelease? + ) result = result.map(&:full_spec) result end @@ -425,7 +428,8 @@ module Vagrant def find_all(req) @specs.select do |spec| - req.match?(spec) + allow_prerelease = spec.name == "vagrant" && Vagrant.prerelease? + req.match?(spec, allow_prerelease) end.map do |spec| Gem::Resolver::InstalledSpecification.new(self, spec) end @@ -474,7 +478,7 @@ module Vagrant # ignored. def load_spec (name, version, platform, source) version = Gem::Version.new(version) if !version.is_a?(Gem::Version) - @specs.fetch(name, []).detect{|s| s.name == name && s.version = version} + @specs.fetch(name, []).detect{|s| s.name == name && s.version == version} end end end