Always force string type conversion of path

Fixes #9984
This commit is contained in:
Chris Roberts 2018-07-06 14:29:32 -07:00
parent 04f7215b5e
commit 6aa5c1a008
2 changed files with 7 additions and 2 deletions

View File

@ -392,8 +392,9 @@ module Vagrant
# @param [String, Pathname] path Path to convert # @param [String, Pathname] path Path to convert
# @return [String] # @return [String]
def wsl_to_windows_path(path) def wsl_to_windows_path(path)
path = path.to_s
if wsl? && wsl_windows_access? && !path.match(/^[a-zA-Z]:/) 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) if wsl_path?(path)
parts = path.split("/") parts = path.split("/")
parts.delete_if(&:empty?) parts.delete_if(&:empty?)
@ -405,7 +406,7 @@ module Vagrant
end end
path = [root_path, *parts].join("\\") path = [root_path, *parts].join("\\")
else else
path = path.to_s.sub("/mnt/", "") path = path.sub("/mnt/", "")
parts = path.split("/") parts = path.split("/")
parts.first << ":" parts.first << ":"
path = parts.join("\\") path = parts.join("\\")

View File

@ -353,6 +353,10 @@ describe Vagrant::Util::Platform do
it "should include rootfs when accessing non-home path" do it "should include rootfs when accessing non-home path" do
expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs") expect(subject.wsl_to_windows_path("/tmp/test")).to include("rootfs")
end end
it "should properly handle Pathname" do
expect(subject.wsl_to_windows_path(Pathname.new("/tmp/test"))).to include("rootfs")
end
end end
end end
end end