Please make sure you are using the latest version of Vagrant, or at least 2.2.15, otherwise it may not be able to run Windows executable files correctly from Linux.
Just add path to
cmd.exe in Linux:
Otherwise, you will get the following error, as you have described:
The executable 'cmd.exe' Vagrant is trying to run was not
found in the PATH variable. This is an error. Please verify
this software is installed and on the path.
You can add the above line to your
~/.profile file and reload it using the following commands:
This way, Vagrant will be able to locate the
Through the environment variable
VAGRANT_WSL_ENABLE_WINDOWS_ACCESS, Vagrant understands that it may access the Windows system to run executable files and use functions such as synced folders. You can find more information about this variable on the corresponding page of the official Vagrant website.
With this variable, Vagrant will start Windows executables files from Linux, including the Windows
cmd.exe command-line interpreter.
There is a YouTube video on how to install Vagrant under Ubuntu 18 in WSL1 of Windows 10 and VirtualBox. However, since this video demonstrates the use of old software, newer software may not work as described in the video. Besides that, the video does not explicitly address the issue with the
cmd.exe that you have described.
In any case, running Vagrant from Linux to create a virtual machine in Windows VirtualBox does not always run smoothly. You may encounter errors similar to the following:
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.
Command: ["startvm", "a1d5c124-261b-4e4b-a11a-88f7bfdda6df", "--type", "headless"]
Stderr: VBoxManage.exe: error: Failed to get device handle and/or partition ID for
0000000001cf34e0 (hPartitionDevice=0000000000000a39, Last=0xc0000002/1)
VBoxManage.exe: error: Details: code E_FAIL (0x80004005), component ConsoleWrap, interface IConsole
To avoid these errors and make Vagrant work reliably, you need to run Linux on physical hardware instead of running from a Windows WSL or Docker container. If you run Linux on physical hardware, VirtualBox will also run on Linux, and Vagrant would not need to communicate between Linux and Windows by running Windows executables on Linux.