VBoxManage: error: Failed to initialize COM! NS_ERROR_FILE_TARGET_DOES_NOT_EXIST (0x80520006)

What an error! And the VirtualBox stopped loading anymore! This error:

myuser@srv ~ $ VBoxManage list vms
VBoxManage: error: Failed to initialize COM! (hrc=NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)

and here with the GIU, which offers a little bit more information about the error ID:
This error occurs despite the successfully loaded VirtualBox kernel modules!

main menu
VBoxManage: error: Failed to initialize COM! NS_ERROR_FILE_TARGET_DOES_NOT_EXIST (0x80520006)

The two errors are the same and hint there is a file missing (or files?)? In our case, after upgrading from virtualbox-bin (a binary package) to a virtualbox (a package, which actually builds the VirtualBox on the system) under Gentoo, but apparently, this error could occur to everyone, who tries to build yourself the VirtualBox bundle.

The solution is simple: just DO NOT CHANGE the installation path of the Virtualbox software, which by default is /opt/VirtualBox.

The path is hardcoded in the sources and cannot be changed! At present version 6.1.16, we could not find a build option to change it! Of course, the linking /opt/VirtualBox would do the trick to move the installation physically away from the /opt, but the path must be valid /opt/VirtualBox.

In Gentoo, the emerge default installation goes to “/usr/lib64/virtualbox“, so the maintainer of the package changed the path and Virtualbox stopped working! Or a user build it and install it in any other location should link the /opt/VirtualBox to the installation directory. For example, in Gentoo, the fix will be:

root@srv ~ $ ln -s /usr/lib64/virtualbox /opt/VirtualBox
root@srv ~ $ exit
myuser@srv ~ $ VBoxManage list vms
"gentoo_raw" {55346caf-04db-4d88-831a-111111111111}
"diskless" {44346caf-c952-5555-b8a3-111111111111}
"diskless-linux" {44346caf-424f-487f-ae8d-111111111111}
"centos7-netinstall" {44346caf-4e86-441b-8d1e-111111111111}

A simple link would bring back Virtualbox to live.

Bonus

Probably, there is a configuration file “xpti.dat” in two or more locations: ~/.config/VirtualBox/xpti.dat and ~/.VirtualBox/xpti.dat, which is generated on every start of a VirtualBox. In the file there are configuration lines like:

# Generated file. ** DO NOT EDIT! **

[Header,2]
0,Version,2,0
1,AppDir,/opt/VirtualBox

[Directories,1]
0,/opt/VirtualBox/components

[Files,2]
0,VirtualBox_XPCOM.xpt,0,61984,1431970176000
1,VBoxXPCOMBase.xpt,0,25931,1431970176000


And the file is really generated by the VirtualBox binary.

When executing VirtualBox (VBoxManage) from a different installation directory and without valid /opt/VirtualBox here is what strace outputs:

  1. The binary generates the configuration file with path /opt/VirtualBox and replaces all previous etries
  2. Cannot find the VirtualBox library files, which are needed for communication with the kernel drivers and that’s why it cannot initialize the COM module.
myuser@srv ~ $ strace -f -s 256 VBoxManage list vms
execve("/usr/bin/VBoxManage", ["VBoxManage", "list", "vms"], 0x7ffef2ac9f98 /* 105 vars */) = 0
brk(NULL)                               = 0x560f30544000
access("/etc/ld.so.preload", R_OK)      = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=540164, ...}) = 0
mmap(NULL, 540164, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7fd04d4a7000
close(3)                                = 0
openat(AT_FDCWD, "/lib64/libreadline.so.8", O_RDONLY|O_CLOEXEC) = 3
....
....
readlink("/proc/self/exe", "/usr/lib64/virtualbox/VBoxManage", 4067) = 32
openat(AT_FDCWD, "/usr/lib64/gconv/gconv-modules.cache", O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=26988, ...}) = 0
mmap(NULL, 26988, PROT_READ, MAP_SHARED, 3, 0) = 0x7f0d2a44a000
close(3)                                = 0
futex(0x7f0d29cb09bc, FUTEX_WAKE_PRIVATE, 2147483647) = 0
brk(0x558e70c32000)                     = 0x558e70c32000
rt_sigaction(SIGCHLD, NULL, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
rt_sigaction(SIGCHLD, {sa_handler=0x7f0d2a24c840, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART|SA_NOCLDSTOP, sa_restorer=0x7f0d2a3bf890}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
geteuid()                               = 1000
stat("/home/myuser", {st_mode=S_IFDIR|0755, st_size=69632, ...}) = 0
stat("/home/myuser/.VirtualBox", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
sched_get_priority_min(SCHED_OTHER)     = 0
sched_get_priority_max(SCHED_OTHER)     = 0
sched_getparam(30467, [0])              = 0
sched_getscheduler(30467)               = 0 (SCHED_OTHER)
sched_setscheduler(30467, SCHED_OTHER, [0]) = 0
socket(AF_INET6, SOCK_STREAM, IPPROTO_IP) = 3
close(3)                                = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f0d2a3bf890}, NULL, 8) = 0
stat("/opt/VirtualBox", 0x558e70c114b0) = -1 ENOENT (No such file or directory)
lstat("/opt/VirtualBox", 0x558e70c114b0) = -1 ENOENT (No such file or directory)
brk(0x558e70c56000)                     = 0x558e70c56000
lstat("/opt", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
lstat("/opt/VirtualBox", 0x7ffe339b2db0) = -1 ENOENT (No such file or directory)
getcwd("/home/myuser", 4096)             = 12
openat(AT_FDCWD, "/home/myuser/.VirtualBox/compreg.dat", O_RDONLY) = 3
fcntl(3, F_GETFD)                       = 0
stat("/home/myuser/.VirtualBox/compreg.dat", {st_mode=S_IFREG|0600, st_size=1401, ...}) = 0
read(3, "Generated File. Do not edit.\n\n[HEADER]\nVersion,0,5\n\n[COMPONENTS]\nrel:VBoxSVCM.so,1580939781000\nrel:VBoxC.so,1580939781000\nrel:VBoxXPCOMIPCC.so,1217513612000,VBoxXPCOM.so libpthread.so libdl.so\n\n[CLASSIDS]\n{d9e56bf8-e32e-4b6d-87f1-06d73b0ce7ca},,,,rel:VBoxX"..., 1401) = 1401
close(3)                                = 0
access("/opt/VirtualBox/.autoreg", F_OK) = -1 ENOENT (No such file or directory)
access("/opt/VirtualBox/plugins", F_OK) = -1 ENOENT (No such file or directory)
stat("/home/myuser/.VirtualBox/xpti.dat", {st_mode=S_IFREG|0600, st_size=204, ...}) = 0
openat(AT_FDCWD, "/home/myuser/.VirtualBox/xpti.dat", O_RDONLY) = 3
fcntl(3, F_GETFD)                       = 0
read(3, "# Generated file. ** DO NOT EDIT! **\n\n[Header,2]\n0,Version,2,0\n1,AppDir,/opt/VirtualBox\n\n[Directories,2]\n0,/opt/VirtualBox/components\n1,/home/myuser/components\n\n[Files,0]\n\n[ArchiveItems,0]\n\n[Interfaces,0]\n", 204) = 204
close(3)                                = 0
stat("/home/myuser/.VirtualBox/xpti.dat", {st_mode=S_IFREG|0600, st_size=204, ...}) = 0
openat(AT_FDCWD, "/home/myuser/.VirtualBox/xpti.dat", O_RDONLY) = 3
fcntl(3, F_GETFD)                       = 0
read(3, "# Generated file. ** DO NOT EDIT! **\n\n[Header,2]\n0,Version,2,0\n1,AppDir,/opt/VirtualBox\n\n[Directories,2]\n0,/opt/VirtualBox/components\n1,/home/myuser/components\n\n[Files,0]\n\n[ArchiveItems,0]\n\n[Interfaces,0]\n", 204) = 204
close(3)                                = 0
openat(AT_FDCWD, "/opt/VirtualBox/components", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/myuser/components", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/myuser/.VirtualBox/xpti.dat.tmp", O_WRONLY|O_CREAT|O_TRUNC, 0600) = 3
fcntl(3, F_GETFD)                       = 0
write(3, "# Generated file. ** DO NOT EDIT! **\n", 37) = 37
write(3, "\n[Header,2]\n", 12)          = 12
write(3, "0,Version,2,0\n", 14)         = 14
write(3, "1,AppDir,/opt/VirtualBox\n", 25) = 25
write(3, "\n[Directories,2]\n", 17)     = 17
write(3, "0,/opt/VirtualBox/components\n", 29) = 29
write(3, "1,/home/myuser/components\n", 25) = 25
write(3, "\n[Files,0]\n", 11)           = 11
write(3, "\n[ArchiveItems,0]\n", 18)    = 18
write(3, "\n[Interfaces,0]\n", 16)      = 16
close(3)                                = 0
access("/home/myuser/.VirtualBox/xpti.dat", F_OK) = 0
stat("/home/myuser/.VirtualBox/xpti.dat", {st_mode=S_IFREG|0600, st_size=204, ...}) = 0
lstat("/home/myuser/.VirtualBox/xpti.dat", {st_mode=S_IFREG|0600, st_size=204, ...}) = 0
unlink("/home/myuser/.VirtualBox/xpti.dat") = 0
access("/home/myuser/.VirtualBox", F_OK) = 0
stat("/home/myuser/.VirtualBox", {st_mode=S_IFDIR|0755, st_size=4096, ...}) = 0
rename("/home/myuser/.VirtualBox/xpti.dat.tmp", "/home/myuser/.VirtualBox/xpti.dat") = 0
pipe([3, 4])                            = 0
fcntl(3, F_SETFD, FD_CLOEXEC)           = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
fcntl(3, F_GETFL)                       = 0 (flags O_RDONLY)
fcntl(3, F_SETFL, O_RDONLY|O_NONBLOCK)  = 0
fcntl(4, F_GETFL)                       = 0x1 (flags O_WRONLY)
fcntl(4, F_SETFL, O_WRONLY|O_NONBLOCK)  = 0
openat(AT_FDCWD, "/home/myuser/VBoxXPCOM.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/myuser/libpthread.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/home/myuser/libdl.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/VirtualBox/components/VBoxXPCOMIPCC.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
openat(AT_FDCWD, "/opt/VirtualBox/components", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
read(3, 0x7ffe339b41d7, 1)              = -1 EAGAIN (Resource temporarily unavailable)
close(3)                                = 0
close(4)                                = 0
write(2, "VBoxManage", 10VBoxManage)              = 10
write(2, ": ", 2: )                       = 2
write(2, "error: ", 7error: )                  = 7
write(2, "Failed to initialize COM! (hrc=NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)", 67Failed to initialize COM! (hrc=NS_ERROR_FILE_TARGET_DOES_NOT_EXIST)) = 67
write(2, "\n", 1
)                       = 1
exit_group(1)                           = ?
+++ exited with 1 +++

Leave a Reply

Your email address will not be published. Required fields are marked *