From c555e4b72fafb1af44313a7c840abfbc1b6cff65 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Mar 2017 10:09:52 -0700 Subject: [PATCH 1/2] Remove subprocess command string re-encoding to default external --- lib/vagrant/util/subprocess.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/vagrant/util/subprocess.rb b/lib/vagrant/util/subprocess.rb index fdaf3564e..7efb1a436 100644 --- a/lib/vagrant/util/subprocess.rb +++ b/lib/vagrant/util/subprocess.rb @@ -25,7 +25,6 @@ module Vagrant def initialize(*command) @options = command.last.is_a?(Hash) ? command.pop : {} @command = command.dup - @command = @command.map { |s| s.encode(Encoding.default_external) } @command[0] = Which.which(@command[0]) if !File.file?(@command[0]) if !@command[0] raise Errors::CommandUnavailableWindows, file: command[0] if Platform.windows? From 154c3be0d4bba5dc6a34c0ca3bae6704a43fec95 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 17 Mar 2017 10:10:50 -0700 Subject: [PATCH 2/2] Join command with given arguments before running exec This resolves issues where directly passing arguments individually to Kernel.exec causes encoding errors due to arguments being forced command/shell encoding which is not always correct. --- lib/vagrant/util/safe_exec.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/safe_exec.rb b/lib/vagrant/util/safe_exec.rb index 37e6a38c3..f7f5bdb81 100644 --- a/lib/vagrant/util/safe_exec.rb +++ b/lib/vagrant/util/safe_exec.rb @@ -40,7 +40,15 @@ module Vagrant Process.wait(pid) end else - Kernel.exec(command, *args) + if Vagrant::Util::Platform.windows? + @@logger.debug("Converting command and arguments to single string for exec") + @@logger.debug("Command: `#{command.inspect}` Args: `#{args.inspect}`") + full_command = "#{command} #{args.join(" ")}" + @@logger.debug("Converted command: #{full_command}") + Kernel.exec(full_command) + else + Kernel.exec(command, *args) + end end rescue *rescue_from # We retried already, raise the issue and be done