From f7e5a9d199613a3d5388d12b4729fe2f801861eb Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Fri, 11 Nov 2022 10:32:32 -0800 Subject: [PATCH 1/2] Force LANG when executing commands This forces the LANG enviroment variable to be set to `"C"` when executing VBoxManage commands. Doing this prevents localization of output which causes failures of the VirtualBox driver when scanning for information. --- plugins/providers/virtualbox/driver/base.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index c2f79e40b..57602b483 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -460,7 +460,9 @@ module VagrantPlugins end # Append in the options for subprocess - command << { notify: [:stdout, :stderr] } + # NOTE: We include the LANG env var set to C to prevent command output + # from being localized + command << { notify: [:stdout, :stderr], env: {LANG: "C"}} Vagrant::Util::Busy.busy(int_callback) do Vagrant::Util::Subprocess.execute(@vboxmanage_path, *command, &block) From 1390837129536a532394f3277f78fe78bf805ca2 Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Mon, 14 Nov 2022 12:49:18 -0800 Subject: [PATCH 2/2] Update expected options in tests --- .../shared/virtualbox_driver_version_5_x_examples.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/unit/plugins/providers/virtualbox/support/shared/virtualbox_driver_version_5_x_examples.rb b/test/unit/plugins/providers/virtualbox/support/shared/virtualbox_driver_version_5_x_examples.rb index ac5cdc56a..eee5aa828 100644 --- a/test/unit/plugins/providers/virtualbox/support/shared/virtualbox_driver_version_5_x_examples.rb +++ b/test/unit/plugins/providers/virtualbox/support/shared/virtualbox_driver_version_5_x_examples.rb @@ -22,11 +22,11 @@ shared_examples "a version 5.x virtualbox driver" do |options| it "enables SharedFoldersEnableSymlinksCreate if true" do expect(subprocess).to receive(:execute). - with("VBoxManage", "setextradata", anything, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/folder", "1", {:notify=>[:stdout, :stderr]}). + with("VBoxManage", "setextradata", anything, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/folder", "1", {:env => {:LANG => "C"}, :notify=>[:stdout, :stderr]}). and_return(subprocess_result(exit_code: 0)) expect(subprocess).to receive(:execute). - with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:notify=>[:stdout, :stderr]}). + with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:env => {:LANG => "C"}, :notify=>[:stdout, :stderr]}). and_return(subprocess_result(exit_code: 0)) subject.share_folders(folders) @@ -34,11 +34,11 @@ shared_examples "a version 5.x virtualbox driver" do |options| it "enables automount if option is true" do expect(subprocess).to receive(:execute). - with("VBoxManage", "setextradata", anything, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/folder", "1", {:notify=>[:stdout, :stderr]}). + with("VBoxManage", "setextradata", anything, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/folder", "1", {:env => {:LANG => "C"}, :notify=>[:stdout, :stderr]}). and_return(subprocess_result(exit_code: 0)) expect(subprocess).to receive(:execute). - with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", "--automount", {:notify=>[:stdout, :stderr]}). + with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", "--automount", {:env => {:LANG => "C"}, :notify=>[:stdout, :stderr]}). and_return(subprocess_result(exit_code: 0)) subject.share_folders(folders_automount) @@ -46,7 +46,7 @@ shared_examples "a version 5.x virtualbox driver" do |options| it "disables SharedFoldersEnableSymlinksCreate if false" do expect(subprocess).to receive(:execute). - with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:notify=>[:stdout, :stderr]}). + with("VBoxManage", "sharedfolder", "add", anything, "--name", "folder", "--hostpath", "/Users/brian/vagrant-folder", {:env => {:LANG => "C"}, :notify=>[:stdout, :stderr]}). and_return(subprocess_result(exit_code: 0)) subject.share_folders(folders_disabled)