diff --git a/plugins/communicators/winssh/communicator.rb b/plugins/communicators/winssh/communicator.rb index 435d20a30..fb82a4a80 100644 --- a/plugins/communicators/winssh/communicator.rb +++ b/plugins/communicators/winssh/communicator.rb @@ -45,7 +45,7 @@ module VagrantPlugins else tfile = Tempfile.new('vagrant-ssh') remote_ext = shell == "powershell" ? "ps1" : "bat" - remote_name = "#{machine_config_ssh.upload_directory}\\#{File.basename(tfile.path)}.#{remote_ext}" + remote_name = "#{machine_config_ssh.upload_directory}/#{File.basename(tfile.path)}.#{remote_ext}" if shell == "powershell" base_cmd = "powershell -File #{remote_name}" diff --git a/plugins/communicators/winssh/config.rb b/plugins/communicators/winssh/config.rb index e6cc9aec7..179096394 100644 --- a/plugins/communicators/winssh/config.rb +++ b/plugins/communicators/winssh/config.rb @@ -14,7 +14,7 @@ module VagrantPlugins def finalize! @shell = "cmd" if @shell == UNSET_VALUE @sudo_command = "%c" if @sudo_command == UNSET_VALUE - @upload_directory = "C:\\Windows\\Temp" if @upload_directory == UNSET_VALUE + @upload_directory = "C:/Windows/Temp" if @upload_directory == UNSET_VALUE if @export_command_template == UNSET_VALUE if @shell == "cmd" @export_command_template = 'set %ENV_KEY%="%ENV_VALUE%"' diff --git a/plugins/provisioners/shell/provisioner.rb b/plugins/provisioners/shell/provisioner.rb index d63f7bfb7..a86a43a42 100644 --- a/plugins/provisioners/shell/provisioner.rb +++ b/plugins/provisioners/shell/provisioner.rb @@ -40,12 +40,17 @@ module VagrantPlugins def upload_path if !defined?(@_upload_path) - @_upload_path = config.upload_path.to_s + case @machine.config.vm.guest + when :windows + @_upload_path = Vagrant::Util::Platform.unix_windows_path(config.upload_path.to_s) + else + @_upload_path = config.upload_path.to_s + end if @_upload_path.empty? case @machine.config.vm.guest when :windows - @_upload_path = "C:\\tmp\\vagrant-shell" + @_upload_path = "C:/tmp/vagrant-shell" else @_upload_path = "/tmp/vagrant-shell" end diff --git a/test/unit/plugins/provisioners/shell/provisioner_test.rb b/test/unit/plugins/provisioners/shell/provisioner_test.rb index 6f49fadad..c3b566df3 100644 --- a/test/unit/plugins/provisioners/shell/provisioner_test.rb +++ b/test/unit/plugins/provisioners/shell/provisioner_test.rb @@ -355,19 +355,21 @@ describe "Vagrant::Shell::Provisioner" do allow(machine).to receive_message_chain(:config, :vm, :guest).and_return(:windows) end - it "should default to C:\\tmp\\vagrant-shell" do - expect(vsp.upload_path).to eq("C:\\tmp\\vagrant-shell") + it "should default to C:/tmp/vagrant-shell" do + expect(vsp.upload_path).to eq("C:/tmp/vagrant-shell") end end end context "when upload_path is set" do + let(:upload_path) { "arbitrary" } + let(:config) { double( :config, :args => "doesn't matter", :env => {}, - :upload_path => "arbitrary", + :upload_path => upload_path, :remote? => false, :path => "doesn't matter", :inline => "doesn't matter", @@ -384,6 +386,18 @@ describe "Vagrant::Shell::Provisioner" do it "should use the value from from config" do expect(vsp.upload_path).to eq("arbitrary") end + + context "windows" do + let(:upload_path) { "C:\\Windows\\Temp" } + + before do + allow(machine).to receive_message_chain(:config, :vm, :guest).and_return(:windows) + end + + it "should normalize the slashes" do + expect(vsp.upload_path).to eq("C:/Windows/Temp") + end + end end context "with cached value" do