hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.18k stars 4.43k forks source link

Vagrant makes LANG=C setting which breaks VBoxManage output #13145

Closed gentoo-root closed 1 year ago

gentoo-root commented 1 year ago

Vagrant sets LANG=C to make VBoxManage output independent of locale. However, on my system (Arch Linux, VirtualBox 7.0.8) VBoxManage doesn't produce any useful output when LANG is set to C. It does, however, produce the needed output when LANG=C.UTF-8.

Debug output

https://gist.github.com/gentoo-root/911854ad48374df6cf0fe116d606fb30

Expected behavior

Vagrant should work, i.e. start a VM with the simple Vagrantfile below.

Actual behavior

vagrant up fails, because vagrant sets LANG=C when it runs VBoxManage commands, and VBoxManage doesn't produce any useful output when LANG=C is set.

Reproduction information

Vagrant version

Vagrant 2.3.4

Host operating system

Arch Linux

Guest operating system

Doesn't matter.

Steps to reproduce

Simple test for VirtualBox:

  1. Make sure VBoxXPCOMIPCD is not running, because it caches the LANG setting. It's usually enough to wait for 5 seconds, unless something is interacting with VirtualBox.
  2. Run LANG=C VBoxManage list systemproperties and observe empty output.
  3. After VBoxXPCOMIPCD quits, run LANG=C.UTF-8 VBoxManage list systemproperties and observe plenty of output.

Vagrant-specific test:

  1. Run VAGRANT_LOG=info vagrant up with the Vagrantfile below.
  2. Observe the error.
  3. Wait for VBoxXPCOMIPCD to quit.
  4. Run LANG=C.UTF-8 VBoxManage list systemproperties | tail -n1; VAGRANT_LOG=info vagrant up. The first command starts VBoxXPCOMIPCD and assigns LANG=C.UTF-8 to it, so even when vagrant uses LANG=C afterwards (within 5 seconds after the first command), vagrant's setting is ignored, and the VBoxManage commands started by vagrant run properly and produce output.
  5. Observe the good log.

Vagrantfile

Vagrant.configure("2") do |config|
  config.vm.box = "ubuntu/jammy64"
  config.vm.synced_folder ".", "/shared"
end
gentoo-root commented 1 year ago

Unfortunately, #13150 didn't fix this bug. locale -a contains both C and C.UTF-8 on my system, so LANG=C is still selected after this patch, and nothing really changes for me.

@chrisroberts, could you please reopen the issue?

DEBUG virtualbox_7_0: list of available C locales: ["C", "C.UTF-8", "en_US.utf8", "POSIX"]
DEBUG virtualbox_7_0: valid variation found for LANG value: C
DEBUG virtualbox_7_0: LANG value set: "C"
chrisroberts commented 1 year ago

@gentoo-root Thanks for the update. I'll reorder the values so C is less preferred.

chrisroberts commented 1 year ago

@gentoo-root if you are able, would you mind giving the dev build a run and see if it resolves your issue: https://github.com/hashicorp/vagrant/releases/tag/2.3.6.dev%2B68b3d94