From 6aa5c1a008fc7ed2c47dba00b45ab82b66c53b3e Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 6 Jul 2018 14:29:32 -0700 Subject: [PATCH 1/2] Always force string type conversion of path Fixes #9984 --- lib/vagrant/util/platform.rb | 5 +++-- test/unit/vagrant/util/platform_test.rb | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 789d61ece..20a389d3e 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -392,8 +392,9 @@ module Vagrant # @param [String, Pathname] path Path to convert # @return [String] def wsl_to_windows_path(path) + path = path.to_s if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/) - path = File.expand_path(path.to_s) + path = File.expand_path(path) if wsl_path?(path) parts = path.split("/") parts.delete_if(&:empty?) @@ -405,7 +406,7 @@ module Vagrant end path = [root_path, *parts].join("\\") else - path = path.to_s.sub("/mnt/", "") + path = path.sub("/mnt/", "") parts = path.split("/") parts.first << ":" path = parts.join("\\") diff --git a/test/unit/vagrant/util/platform_test.rb b/test/unit/vagrant/util/platform_test.rb index f43afd1d8..396148839 100644 --- a/test/unit/vagrant/util/platform_test.rb +++ b/test/unit/vagrant/util/platform_test.rb @@ -353,6 +353,10 @@ describe Vagrant::Util::Platform do it "should include rootfs when accessing non-home path" do expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs") end + + it "should properly handle Pathname" do + expect(subject.wsl_to_windows_path(Pathname.new("/tmp/test"))).to include("rootfs") + end end end end From 6f81d16691543c544b7a44164b477a27ffafd650 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 12 Jul 2018 16:49:22 -0700 Subject: [PATCH 2/2] Remove final #to_s on path --- lib/vagrant/util/platform.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index 20a389d3e..e1f2ea29c 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -412,7 +412,7 @@ module Vagrant path = parts.join("\\") end end - path.to_s + path end # Takes a windows path and formats it to the