Vagrant wsl cant access virtualbox
Asked Answered
S

0

7

I have a frustrating problem. I want to run Vagrant from within WSL. I followed the guide on Vagrant: https://www.vagrantup.com/docs/other/wsl.html

After following the guide I created a Vagrantfile with the following:

Vagrant.configure(2) do |config|
  config.vm.provider "virtualbox" do |vb|
    vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ]
  end
  config.vm.box = "ubuntu/xenial64"
  config.vm.network "forwarded_port", guest: 8000, host: 8001

end

My environment variables that I created are the following:

PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/mnt/c/Windows/System32/:/mnt/c/Program:/mnt/c/Program Files/Oracle/VirtualBox
VAGRANT_WSL_ENABLE_WINDOWS_ACCESS=1

This link provides the output of vagrant up --debug: https://pastebin.com/MT40DLHT

Does anyone know what I am doing wrong?

Snowber answered 28/7, 2017 at 14:24 Comment(9)
can you check if you can run VBoxManage --version from wsl ? it probably won't work, you'd need to fix your PATH (check where VBoxManage program is installed and put this folder in your PATH, not the main VirtualBox directory, there might be a subdirectory but I don't have windows available to check)Thoreau
@FrédéricHenri I found out that there was something wrong with my PATH and I had to do Windows updates. Now that is fixed I'm getting really close. I now get the following error: The executable 'vagrant.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. But does this mean that I need to install vagrant on Windows as well?Snowber
add the path of vagrant.exe to your PATH variable and it should workThoreau
Okay, but does this really mean that I should install vagrant within wsl and on WIndows as well to get it to work?Snowber
@HaijePloeg What did you conclude? I also followed the guide on HashiCorp's website for WSL and am receiving the same error (vagrant.exe not in PATH).Xenomorphic
@gmask You should use the latest version of Windows, the latest update exports all the path variables of Windows to WSL, so you can use windows exe files in wsl. You should also use VAGRANT_WSL_ENABLE_WINDOWS_ACCESS=1. To manually export vagrant.exe, use: `export PATH=/mnt/c/location/to/vagrant:$PATHSnowber
I am on the latest version of Windows insider running Ubuntu 16.04 and have that command in bash. What you're saying though is that I need to install Vagrant in Windows as well using the installer .exe, not just in Ubuntu using the .Deb, which completely defeats the purpose of having it in WSL anyway... Right?Xenomorphic
Hi, yes you should install it in Windows as well. But the Vagrant on Windows comes with some limitations, such as it relies on git ssh, no rsync and a some other things. With vagrant within WSL you have a fully working vagrant installation on a Windows host.Snowber
github.com/hashicorp/vagrant/issues/8962#issuecomment-334579481 Have a look here how I got it working.Whitcher

© 2022 - 2024 — McMap. All rights reserved.