From 8b398b66a3c7c3e549f4169f3b13ac62c7b14b03 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 3 May 2018 09:25:42 -0700 Subject: [PATCH] Trim drive letter prefix from path Fixes #9764 --- plugins/provisioners/chef/provisioner/chef_solo.rb | 7 ++++--- .../provisioners/chef/provisioner/chef_solo_test.rb | 12 +++++++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/plugins/provisioners/chef/provisioner/chef_solo.rb b/plugins/provisioners/chef/provisioner/chef_solo.rb index 676d40d7a..170684d9a 100644 --- a/plugins/provisioners/chef/provisioner/chef_solo.rb +++ b/plugins/provisioners/chef/provisioner/chef_solo.rb @@ -101,7 +101,8 @@ module VagrantPlugins # of a hack but is the most portable way I can think of at the moment # to achieve this. Otherwise, Vagrant attempts to share at some crazy # path like /home/vagrant/c:/foo/bar - remote_path = File.expand_path(path.gsub(/^[a-zA-Z]:\//, "/"), guest_provisioning_path.gsub(/^[a-zA-Z]:\//, "/")) + remote_path = File.expand_path(path.sub(/^[a-zA-Z]:\//, "/"), guest_provisioning_path.sub(/^[a-zA-Z]:\//, "/")) + remote_path.sub!(/^[a-zA-Z]:\//, "/") end # If we have specified a folder name to append then append it @@ -183,10 +184,10 @@ module VagrantPlugins ) still_active = 259 #provisioner has asked chef to reboot - + @config.attempts.times do |attempt| exit_status = 0 - while exit_status == 0 || exit_status == still_active + while exit_status == 0 || exit_status == still_active if @machine.guest.capability?(:wait_for_reboot) @machine.guest.capability(:wait_for_reboot) elsif attempt > 0 diff --git a/test/unit/plugins/provisioners/chef/provisioner/chef_solo_test.rb b/test/unit/plugins/provisioners/chef/provisioner/chef_solo_test.rb index 1282740d3..16a837ddd 100644 --- a/test/unit/plugins/provisioners/chef/provisioner/chef_solo_test.rb +++ b/test/unit/plugins/provisioners/chef/provisioner/chef_solo_test.rb @@ -23,12 +23,22 @@ describe VagrantPlugins::Chef::Provisioner::ChefSolo do end describe "#expanded_folders" do + before { allow(subject).to receive(:windows?).and_return(true) } + it "handles the default Windows provisioning path" do allow(config).to receive(:provisioning_path).and_return(nil) - allow(subject).to receive(:windows?).and_return(true) remote_path = subject.expanded_folders([[:vm, "cookbooks-1"]])[0][2] expect(remote_path).to eq("/vagrant-chef/cookbooks-1") end + + it "removes drive letter prefix from path" do + allow(config).to receive(:provisioning_path).and_return(nil) + expect(File).to receive(:expand_path).and_return("C:/vagrant-chef/cookbooks-1") + result = subject.expanded_folders([[:vm, "cookbooks-1"]]) + remote_path = result[0][2] + expect(remote_path).to eq("/vagrant-chef/cookbooks-1") + end + end describe "#expanded_folders" do