engineer-365 / engineer365-infrastructure

MIT License
4 stars 1 forks source link

Vagrant box initialization failed, got error 'There was an error while executing `VBoxManage`,....' #3

Open CNYuYang opened 3 years ago

CNYuYang commented 3 years ago

Error message:

==> default: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "c414974e-20ef-4c5b-87c5-d003143f7f3b", "--type", "headless"]

Stderr: VBoxManage: error: RawFile#0 failed to create the raw output file /home/qiangyt/engineer365.org/repos/cloud-native-micro-service-engineering/infra/virtualbox/boxes/ubuntu-bionic/ubuntu-bionic-18.04-cloudimg-console.log (VERR_FILE_NOT_FOUND)
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component ConsoleWrap, interface IConsole

Looks like it depends /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/ubuntu-bionic-18.04-cloudimg-console.log

qiangyt commented 3 years ago

Confirmed it is a bug: builder1 box depends on ubuntu-bionic box build log, and I'm sure the build script doesn't hardcode such a path, but not yet find how to fix it. The workaround is either to build the ubuntu-bionic box by yourself or create an empty directory as below:

sudo mkdir -p /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/
sudo chown -R ${USER}:${USER}  /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/

This issue is also collected by README.md FAQ.

Keep it open till we find a solution.

qiangyt commented 3 years ago

This is a really critical issue. I will edit and open it by English.

suntoe commented 3 years ago

I find the root cause. That log file is specified in base ubuntu bionic box, whose Vagrantfile is:

include_vagrantfile = File.expand_path("../include/_Vagrantfile", __FILE__)
load include_vagrantfile if File.exist?(include_vagrantfile)

Vagrant.configure("2") do |config|
  config.vm.base_mac = "021D48B0D5B9"

  config.vm.provider "virtualbox" do |vb|
     vb.customize [ "modifyvm", :id, "--uart1", "0x3F8", "4" ]
     vb.customize [ "modifyvm", :id, "--uartmode1", "file", File.join(Dir.pwd, "ubuntu-bionic-18.04-cloudimg-console.log") ]
  end
end

And my build folder is /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/, so the build log is hardcoded during building.

qiangyt commented 3 years ago

I think the solution is to build the ubuntu bionic box without hardcoded log file path. For now, I don't have experience to build such a box from scratch. Will try it.

Re-post the workaround here:

sudo mkdir -p /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/
sudo chown -R ${USER}:${USER}  /var/engineer365/repos/engineer365-infrastructure/virtualbox/boxes/ubuntu-bionic/
qiangyt commented 3 years ago

PR: https://github.com/engineer-365/engineer365-infrastructure/pull/4 Comimt: https://github.com/engineer-365/engineer365-infrastructure/pull/4/commits/7b3fceeb15ca46b8018ae2cbf3d427441faabee5

qiangyt commented 3 years ago

Verified in another new machine, found this issue not fixed yet.

qiangyt commented 3 years ago

Found 2 related issues somewere: