From 4f877ffb3d6e6bf827ebcca6ca7ba6d65b00b473 Mon Sep 17 00:00:00 2001 From: AskAlice Date: Mon, 26 Apr 2021 19:43:04 -0600 Subject: [PATCH 1/2] add VAGRANT_WSL_NESTED_VIRTUALIZATION env variable --- lib/vagrant/util/platform.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/util/platform.rb b/lib/vagrant/util/platform.rb index c8658e185..f6fc564b8 100644 --- a/lib/vagrant/util/platform.rb +++ b/lib/vagrant/util/platform.rb @@ -44,7 +44,8 @@ module Vagrant @_wsl = false SilenceWarnings.silence! do # Find 'microsoft' in /proc/version indicative of WSL - if File.file?('/proc/version') + # When VAGRANT_WSL_NESTED_VIRTUALIZATION is true, @_wsl will remain false, acting as if not on WSL + if File.file?('/proc/version') && !ENV["VAGRANT_WSL_NESTED_VIRTUALIZATION"] osversion = File.open('/proc/version', &:gets) if osversion.downcase.include?("microsoft") @_wsl = true From 9c766f0f725d29d300c34fca5a75268668f342bc Mon Sep 17 00:00:00 2001 From: AskAlice Date: Mon, 26 Apr 2021 19:43:44 -0600 Subject: [PATCH 2/2] add docs to error messages --- templates/locales/en.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 8cb1971af..2e87f0ddf 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -1867,6 +1867,8 @@ en: Please ensure both installation of Vagrant are the same. If you do not want update your Vagrant installations you can disable Windows access by unsetting the `VAGRANT_WSL_ACCESS_WINDOWS_USER` environment variable. + You can also use nested virtualization within WSL2 by setting + the `VAGRANT_WSL_NESTED_VIRTUALIZATION` environment variable. Windows Vagrant version: %{windows_version} Windows Subsystem for Linux Vagrant version: %{wsl_version} @@ -1874,16 +1876,21 @@ en: Vagrant will not operate outside the Windows Subsystem for Linux unless explicitly instructed. Due to the inability to enforce expected Linux file ownership and permissions on the Windows system, Vagrant will not make modifications to prevent - unexpected errors. To learn more about this, and the options that are available, + unexpected errors. You can use nested virtualization within WSL2 by setting + the `VAGRANT_WSL_NESTED_VIRTUALIZATION` environment variable. + To learn more about this, and the options that are available, please refer to the Vagrant documentation: https://www.vagrantup.com/docs/other/wsl.html wsl_virtualbox_windows_access: |- Vagrant is unable to use the VirtualBox provider from the Windows Subsystem for Linux without access to the Windows environment. Enabling this access must be - done with caution and an understanding of the implications. For more information - on enabling Windows access and using VirtualBox from the Windows Subsystem for - Linux, please refer to the Vagrant documentation: + done with caution and an understanding of the implications. + You can use providers within WSL2 via nested virtualization by setting + the `VAGRANT_WSL_NESTED_VIRTUALIZATION` environment variable. + For more information on enabling Windows access and using VirtualBox from the + Windows Subsystem for Linux, please refer to the Vagrant documentation: + https://www.vagrantup.com/docs/other/wsl.html wsl_rootfs_not_found_error: |-