-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Description
Vagrant version
Vagrant 2.0.2
Host operating system
Windows 10 (version 1709
, build 16299.125
).
Expected behavior
Vagrant is to detect current WSL container and compute a proper path to it.
Actual behavior
Vagrant handles only the WSL that is installed via lxrun
.
References
- Location of WSL rootfs filesystem for post - Fall Creator's Update installations microsoft/WSL#2578
- Plugin is broken in WSL after Windows 10 Fall Creators Update berkshelf/vagrant-berkshelf#323
- https://github.com/BR0kEN-/cikit/tree/issues/52/docs/vagrant/wsl
- Error when installing Arch Linux rootfs on Windows 10 Fall Creators Update RoliSoft/WSL-Distribution-Switcher#69
Additional information
Before the 16215
build of Windows, there was a way to install a WSL using lxrun
. After mentioned build this way has been deprecated and, since then, it's recommended to use Microsoft Store for installing a WSL. Moreover, since that version, you can have multiple instances of Linux subsystem.
When the installation is done by lxrun /install
then rootfs
of a WSL will be in %LOCALAPPDATA%\lxss
and Vagrant will operate correctly since its codebase relies on this location (https://github.com/hashicorp/vagrant/blob/v2.0.1/lib/vagrant/util/platform.rb#L286-L289).
When the installation is done from the Microsoft Store, then rootfs
of a WSL will be in %LOCALAPPDATA%\Packages\<WSL_ID>\LocalState
. Pay your attention at the <WSL_ID>
token in the path which is completely dynamic.
The path of the particular container can be obtained from the registry at HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss
- a listing of installed subsystems.
For instance, using the following PowerShell script, the path of default subsystem can be gained.
$WSLREGKEY="HKCU:\Software\Microsoft\Windows\CurrentVersion\Lxss"
$WSLDEFID=(Get-ItemProperty "$WSLREGKEY").DefaultDistribution
$WSLFSPATH=(Get-ItemProperty "$WSLREGKEY\$WSLDEFID").BasePath
New-Item -ItemType Junction -Path "$env:LOCALAPPDATA\lxss" -Value "$WSLFSPATH\rootfs"