From 6be63b92e202c38d52d9bfd905adc4575c63141b Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 1 Nov 2024 12:41:25 -0700 Subject: [PATCH] Force encoding on command output strings Incompatible encodings will result in an error when the exception is translated. The outputs may not be UTF-8 encoded so force the encoding when providing the values in the exception. --- plugins/providers/virtualbox/driver/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index 8e95cd7f076..7d1739ba26f 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -442,8 +442,8 @@ def execute(*command, &block) if errored raise Vagrant::Errors::VBoxManageError, command: command.inspect, - stderr: r.stderr, - stdout: r.stdout + stderr: r.stderr.to_s.force_encoding("UTF-8"), + stdout: r.stdout.to_s.force_encoding("UTF-8") end end