From f14e8bcbf2a52620aa91ab6724483bb99eef7b34 Mon Sep 17 00:00:00 2001 From: Stefan Scherer Date: Wed, 2 May 2018 22:36:17 +0200 Subject: [PATCH] Allow other providers in WSL --- lib/vagrant/errors.rb | 4 ---- plugins/providers/virtualbox/driver/base.rb | 13 ++++++++++++- templates/locales/en.yml | 10 ---------- 3 files changed, 12 insertions(+), 15 deletions(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 3b2e979af..961d217bd 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -844,10 +844,6 @@ module Vagrant error_key(:vboxmanage_not_found_error) end - class VBoxManageNotFoundWSLError < VagrantError - error_key(:vboxmanage_not_found_wsl_error) - end - class VirtualBoxBrokenVersion040214 < VagrantError error_key(:virtualbox_broken_version_040214) end diff --git a/plugins/providers/virtualbox/driver/base.rb b/plugins/providers/virtualbox/driver/base.rb index 76f08487e..8f07c4bac 100644 --- a/plugins/providers/virtualbox/driver/base.rb +++ b/plugins/providers/virtualbox/driver/base.rb @@ -74,7 +74,18 @@ module VagrantPlugins @logger.debug("Linux platform detected but executing within WSL. Locating VBoxManage.") @vboxmanage_path = Vagrant::Util::Which.which("VBoxManage") || Vagrant::Util::Which.which("VBoxManage.exe") if !@vboxmanage_path - raise Vagrant::Errors::VBoxManageNotFoundWSLError + # If we still don't have one, try to find it using common locations + drive = "/mnt/c" + [ + "#{drive}/Program Files/Oracle/VirtualBox", + "#{drive}/Program Files (x86)/Oracle/VirtualBox" + ].each do |maybe| + path = File.join(maybe, "VBoxManage.exe") + if File.file?(path) + @vboxmanage_path = path + break + end + end end end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 4cc23771e..9b3fcc543 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1513,16 +1513,6 @@ en: log out and log back in for the new environmental variables to take effect. If you're on Linux or Mac, verify your PATH contains the folder that has VBoxManage in it. - vboxmanage_not_found_wsl_error: |- - The "VBoxManage.exe" command or one of its dependencies could not - be found. Please verify VirtualBox is properly installed. You can verify - everything is okay by running "VBoxManage.exe --version" and verifying - that the VirtualBox version is outputted. - - If you just installed VirtualBox, you have to log out and log back in for - the new environmental variables to take effect. Using the VirtualBox - provider within the WSL requires VirtualBox executables to be available - on the system PATH. virtualbox_broken_version_040214: |- Vagrant detected you have VirtualBox 4.2.14 installed. VirtualBox 4.2.14 contains a critical bug which prevents it from working with