wslpath
wslpath copied to clipboard
The user's home dir is in a different path when Ubuntu is installed from the Microsoft Store
After a Windows reinstall, Ubuntu was installed differently, and the users' ~ path was in a different Windows location, now it is here:
C:\Users\{name}\AppData\Local\Local\Packages\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\LocalState\
I am not sure if the string right after UbuntuonWindows varies for each installation.
To make it work again, I just changed a line on the function called lxssPath to this:
$lxssPath_ = trim(exec('cmd.exe /c "echo %LOCALAPPDATA%" 2> /dev/null')) . "\\Packages\\CanonicalGroupLimited.UbuntuonWindows_79rhkp1fndgsc\\LocalState\\rootfs";
I hope this helps.
Hmm, yes maybe now that WSL can support multiple Linux images, this trick won't work properly. Thanks anyway for sharing in case it helps somebody.
May be this ~ path could be saved on some config file, If Users path differs then User could change it manually.