From 1378eebea9bf785acdbb58b617d54169ff501792 Mon Sep 17 00:00:00 2001 From: Mark Mickan Date: Wed, 20 Jan 2016 10:22:00 +1030 Subject: [PATCH] Use pristine version string when constructing path to box Without this change, the version string may be mutated when passed through Gem::Version.new(version).to_s before being used to construct the box directory. This is a problem when using prerelease version numbers because, for example, it will look for "~/.vagrant.d/boxes/1.0.0.pre.alpha.1" when it should be looking for "~/.vagrant.d/boxes/1.0.0-alpha.1". --- lib/vagrant/box_collection.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/vagrant/box_collection.rb b/lib/vagrant/box_collection.rb index 6e83ad4ee..24e1c7124 100644 --- a/lib/vagrant/box_collection.rb +++ b/lib/vagrant/box_collection.rb @@ -276,17 +276,16 @@ module Vagrant next if versiondir.basename.to_s.start_with?(".") version = versiondir.basename.to_s - Gem::Version.new(version) end.compact # Traverse through versions with the latest version first versions.sort.reverse.each do |v| - if !requirements.all? { |r| r.satisfied_by?(v) } + if !requirements.all? { |r| r.satisfied_by?(Gem::Version.new(v)) } # Unsatisfied version requirements next end - versiondir = box_directory.join(v.to_s) + versiondir = box_directory.join(v) providers.each do |provider| provider_dir = versiondir.join(provider.to_s) next if !provider_dir.directory? @@ -303,7 +302,7 @@ module Vagrant end return Box.new( - name, provider, v.to_s, provider_dir, + name, provider, v, provider_dir, metadata_url: metadata_url, ) end